spinner If Strings** == not working

后端 未结 2 1884
面向向阳花
面向向阳花 2021-01-23 21:54

Why is this not working ?!

if(itemx == \"Test number item 0\")
    {
    Log.i(\"Dropdown\", \"inside if\");
    us_lo_ans_hold.setText(\"0x\");
    }; 
<         


        
2条回答
  •  清歌不尽
    2021-01-23 22:04

    Never compare Strings with ==, use equals:

    if(itemx.equals("Test item 0")){...
    

    As for onNothingSelected, the documentation states it will be called for example if you delete the selected item from your adapter.

提交回复
热议问题