spinner If Strings** == not working

后端 未结 2 1906
面向向阳花
面向向阳花 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:24

    If your itemx is a variable then you cant compare two strings with ==. Use instead items.equals("Test number item 0");

    == compares objects and equals() compare string values. Take a look a this post.

提交回复
热议问题