开发者

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().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜