Android setPressed 行为
下面的代码尝试模拟击键:
button1.setPressed(true);
try {
Thread.sleep(500);
} catch(InterruptedException e) {
}
button1.setPressed(false);
上面的代码对按钮没有任何作用,但
button1.setPressed(true);
它本身将按钮设置为按下状态。
为什么第一个片段对按钮没有影响?
The following code is an attempt to simulate a key stroke:
button1.setPressed(true);
try {
Thread.sleep(500);
} catch(InterruptedException e) {
}
button1.setPressed(false);
The above does nothing at all to the button, but
button1.setPressed(true);
by itself sets the button to it's pressed state.
Why does the first snippet have no effect on the button?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回复较晚,但我的猜测是因为您阻塞了 UI 线程,因此在您再次禁用按下状态之前它不会更新 UI。
相反,你可以尝试类似的事情;
祝你好运!
Late reply, but my guess would be because you are blocking the UI-thread, so it will not update the UI until you've already disabled the pressed state again.
Instead you could try something like;
Good luck!