开发者

Honeycomb spinner select item at position 0 doesn't trigger onItemSelected

开发者 https://www.devze.com 2023-03-25 20:38 出处:网络
I\'m using the spinner widget in Honeycomb. When the view loads, the spinner is shown and the item at position 0 is selected. If I click the spinner and change the selection, the onItemSelected() meth

I'm using the spinner widget in Honeycomb. When the view loads, the spinner is shown and the item at position 0 is selected. If I click the spinner and change the selection, the onItemSelected() method is fired. However, if I click the spinner and select the same item (at position 0 by default), the onItemSelected() method does not fire. We want to take immediate action when the user makes a selection, but this does not seem to work for the first item. Is this a bug? Is there a way to make this work? I'm confused because the method is called onItemSelect(), so any selection should trigger it, not just a one 开发者_JS百科that is different than the current selection.

Also, does the prompt no longer do anything for spinners in Honeycomb?


"Selection" is apparently defined as changing the state of an item from unselected to selected.

If you want to raise an event every time you click any of the items, you may have to programmatically change the selection to some default "no action" item after every selection, so as to reset the selectability of your other items. Not ideal, I agree. You might also want to make use of the prompt attribute here.

0

精彩评论

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

关注公众号