Android Spinner: Get the selected item change event

前端 未结 16 2398
挽巷
挽巷 2020-11-22 16:47

How can you set the event listener for a Spinner when the selected item changes?

Basically what I am trying to do is something similar to this:

spinn         


        
16条回答
  •  长情又很酷
    2020-11-22 17:53

    By default, you will get the first item of the spinner array through

    value = spinner.getSelectedItem().toString();
    

    whenever you selected the value in the spinner this will give you the selected value

    if you want the position of the selected item then do it like that

    pos = spinner.getSelectedItemPosition();
    

    the above two answers are for without applying listener

提交回复
热议问题