Android Preventing Double Click On A Spinner

穿精又带淫゛_ 提交于 2019-12-11 04:48:44

问题


I have an unwanted problem by default in spinner view.

On Android 2.2 when I double click any spinner it opens twice, Upon pressing the back button the 2nd spinner closes but 1st one remains open.

I need a fix for this issue.

I only want the spinner to show once regardless of how many times the user clicks it.

This problem doesn't exist in Android 4.0+.

Is there a way to fix this bug?


回答1:


You can use setEnabled(false) when user click on item first time to prevent further interaction, and make setEnabled(true) when you need.




回答2:


You can use something like this,

Possibly in your onClick();

view.setEnabled(false);

new Handler().postDelayed(new Runnable() {
@Override
public void run() {
view.setEnabled(true);
}
}, TIME_IN_MS);


来源:https://stackoverflow.com/questions/16460644/android-preventing-double-click-on-a-spinner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!