Android Preventing Double Click On A Spinner

2019-08-04 17:14发布

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?

2条回答
再贱就再见
2楼-- · 2019-08-04 17:18

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

查看更多
趁早两清
3楼-- · 2019-08-04 17:19

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);
查看更多
登录 后发表回答