ignore OnItemSelectedListener firing on create

后端 未结 5 1511
悲&欢浪女
悲&欢浪女 2021-02-19 06:48

I\'m creating a spinner and I\'ve added an OnItemSelectedListener to it. However I\'ve noticed that it fires on create. Now I was wondering if there wa

5条回答
  •  盖世英雄少女心
    2021-02-19 07:23

    This may help you.

    @Override  
    public void onItemSelected( AdapterView parent, View view, int position, long id)
    {
        if(view!=null &&  view.getId()!=0){
            //do your code here to avoid callback twice 
        }
    }
    

提交回复
热议问题