How to make On Item Selected not automatically choose the first entry

后端 未结 4 628
小蘑菇
小蘑菇 2020-12-30 07:09

I have created a spinner which is automatically updated with appliance names when a person adds an appliance using an array adapter. I created an OnItemSelected method with

4条回答
  •  轮回少年
    2020-12-30 07:49

    It worked for me,

    private boolean isSpinnerInitial = true;

        @Override
        public void onItemSelected(AdapterView parent, View view,
                int position, long id) {
    
            if(isSpinnerInitial)
            {
                isSpinnerInitial = false;
            }
            else  {
                // do your work...
            }
    
        }
    

提交回复
热议问题