gpt4 book ai didi

android - variable string = value(string) 但结果为假

转载 作者:行者123 更新时间:2023-11-30 00:42:42 25 4
gpt4 key购买 nike

请帮忙,

为什么结果 if(Title.toString().trim() == "camera")false
我的代码:

mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
//Get item at position
GridMenuItem item = (GridMenuItem) parent.getItemAtPosition(position);
String Title =item.getTitle();
if(Title.toString().trim() == "camera"){

String strPhoneNumber;
Bundle b = getIntent().getExtras();
strPhoneNumber = b.getString("phonenumber");

Intent myIntent = new Intent(v.getContext(), UploadActivity.class);
Bundle bs = new Bundle();
bs.putString("phonenumber", strPhoneNumber); //Your id
myIntent.putExtras(b); //Put your id to your next Intent
startActivityForResult(myIntent, 0);
finish();
}
if(Title.toString() =="history"){
Intent myIntent = new Intent(v.getContext(), HistoryActivity.class);
startActivityForResult(myIntent, 0);
}
if(Title.toString() =="setting"){
Intent myIntent = new Intent(v.getContext(), HistoryActivity.class);
startActivityForResult(myIntent, 0);
}

}
});

debug

最佳答案

像这样更改代码:

mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
//Get item at position
GridMenuItem item = (GridMenuItem) parent.getItemAtPosition(position);
String Title =item.getTitle().toString().trim();
Log.d("testString",Title);
if(Title.equals("camera")){

String strPhoneNumber;
Bundle b = getIntent().getExtras();
strPhoneNumber = b.getString("phonenumber");

Intent myIntent = new Intent(v.getContext(), UploadActivity.class);
Bundle bs = new Bundle();
bs.putString("phonenumber", strPhoneNumber); //Your id
myIntent.putExtras(b); //Put your id to your next Intent
startActivityForResult(myIntent, 0);
finish();
}
if(Title.equals("history")){
Intent myIntent = new Intent(v.getContext(), HistoryActivity.class);
startActivityForResult(myIntent, 0);
}
if(Title.equals("setting")){
Intent myIntent = new Intent(v.getContext(), HistoryActivity.class);
startActivityForResult(myIntent, 0);
}

}
});

请在下面的评论中发布日志“testString”的值。查看它是否显示“Camera”而不是“camera”,然后相应地更改 if 语句。

关于android - variable string = value(string) 但结果为假,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42312922/

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