开发者

onItemSelectedListener only triggered if selection actually change?

开发者 https://www.devze.com 2023-03-27 13:43 出处:网络
I use setOnItemSelectedListener on a spinner. The listener is triggered if I change the selection but not开发者_运维问答 if I select the same item that is already selected.

I use setOnItemSelectedListener on a spinner. The listener is triggered if I change the selection but not开发者_运维问答 if I select the same item that is already selected. I need to be nofified even if the user select the same item that is already selected. I tought about using setOnItemClickListener but it is not supported by the Spinner.

Any hints ?

TIA


If you're still looking for a solution to this question, Regis, it may be worth having a look at a related question I asked a while ago, which has several answers with good ideas on how to work around this issue.


Did you tried to override onNothingSelected()? in onNS() you implement to do/get/whatever item that is selected by "default". I hope you get my idea.

spin.setOnItemSelectedListener(new OnItemSelectedListener(){

@Override
    public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
                        // Some operation with other selection
                            }
    @Override
      public void onNothingSelected(AdapterView<?> arg0) {
    //operation with that item that onItemSelected() did not triggered. I mean, let's say you have 3 items on the spinner: A,B,C. Initially what we see its the A item and on this item this method will apply.
    }});
0

精彩评论

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

关注公众号