Android Spinner: How to catch when user exits spin

2019-02-23 17:17发布

When a spinner comes up, it usually has a value preselected. If the users explicitly selects another item, my onClickItem handler is getting called. But i did not find a way to detect when the user wants to keep the the currently selected list_item as is? How is the user supposed to exit such a spinner when they like the current value? Could you add a close button or something to just let them exit without having to reselect the already selected item to exit? Also if they do reselect same item, how do you detect this? I don't think my handlers are getting called for this.

To be clear I need to know two things:

1) when user want to keep current value how do they exit the spinner? Is it by reselecting the already selected item. If this is the case, how do I detect this in code so I can close out the dialog?

2) are there any other options for letting user close out a spinner without having them reselect the already selected value? for example providing a dialog close button? Would like to know how others are handling this. Thanks

1条回答
\"骚年 ilove
2楼-- · 2019-02-23 17:53

The user can exit the spinner's dialog by pressing the hardware back key. That's what the key is for - to back out of activities and dialogs. If the currently selected item is selected, that also exits the spinner's dialog. There's generally no need for special handling to allow cancelling the selection, since the the user can directly exit the spinner dialog without making a selection.

查看更多
登录 后发表回答