Spinner item gets automatically selected upon entering activity. How do I avoid this?

后端 未结 8 1794
抹茶落季
抹茶落季 2020-12-18 20:04

I have a spinner in my Android app, and its onItemSelected() event automatically gets triggered upon entering the activity.

How do I avoid this?

8条回答
  •  攒了一身酷
    2020-12-18 21:00

    I have solved this issue, You can avoid this issue by not setting any default values to the spinner

            int initialposition=spinner.getSelectedItemPosition();
            spinner.setSelection(initialposition, false);
    

    This will avoid entering into onItemSelected()

提交回复
热议问题