开发者

android auto active click event

开发者 https://www.devze.com 2023-04-02 06:21 出处:网络
I have a function about accelemeter sensor. I want when I shake the device, the onclick event on a button could be actived.

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

精彩评论

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

关注公众号