android auto active click event
I have a function about accelemeter sensor. I want when I shake the device, the onclick event on a button could be actived. for example:
btn1 = (btn1)findviewbyid(R.id.btn1);
btn1.setonclickListener(new View.onclick(){
//something happend
});
public void onSensorChanged(SensorEvent event) {
//when 开发者_开发知识库I shake, auto active onlick listener
}
How can I trigger the button onclick event? cheers!
You can simulate button click via btn1.performClick()
.
精彩评论