gpt4 book ai didi

android - 微调 onitemclicklistener 不工作

转载 作者:行者123 更新时间:2023-11-29 16:04:14 27 4
gpt4 key购买 nike

我的应用程序中有一个微调器,但在单击某个项目时它不起作用。我得到了值,但 if 条件不起作用。

spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
Object item = parent.getItemAtPosition(pos);

String Text = effecttwo.getSelectedItem().toString();
System.out.println("spinner is -"+item+"-");

// I get the correct values in System.out.println

if(Text=="Hue"){

// not entering into this condition or any other condition

}else if(Text=="Saturation"){


}else if(Text=="Brightness"){



}else{

}


}
public void onNothingSelected(AdapterView<?> parent) {
}
});

请告诉我我做错了什么。

最佳答案

I get the values but the if condition is not getting worked.

if(Text=="Hue"){

使用.equals.equalsIgnoreCase 比较字符串

http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#equals(java.lang.Object)

if(Text.equals("Hue"))
{

}

What is the difference between == vs equals() in Java?

关于android - 微调 onitemclicklistener 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20917610/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com