私は明らかにアンドロイドでは非常に難しいreallllly単純な何かをしようとしています。 2つの文字列を比較して、等しいかどうかを確認したいだけです。文字列の比較の問題
私は「私はこれをデバッグしているし、それが実際に は、だから私は最初
if(temp == "Location") { //do something }
でこれを試してみました。しかし、私はすでにdoesnのことを知っている...場所が含まれていない値「場所」 で一時変数を持っています仕事。
.equals .contains .ignoreCaseEquals 等...誰か助けてください何をすべきかどんな考えを持っている場合
:私はその後のような文字列のすべての可能な機能を試してみました。これは本当に迷惑になっています。
編集: ここでは、私が見たいと思っているものの文字列を比較している関数です。
public String[] getData(){
try {
int tempGroupCount = 0;
URL food_url = new URL (Constants.SERVER_DINING);
BufferedReader my_buffer = new BufferedReader(new InputStreamReader(food_url.openStream()));
temp = my_buffer.readLine();
// prime read
while (temp != null){
// check to see if readline equals Location
Log.w("HERasdfsafdsafdsafE", temp);
// start a new location
if (temp.equals("Location")
{
groups[tempGroupCount] = temp;
tempGroupCount++;
}
Log.w("HERasdfsafdsafdsafE", temp);
//start for-loop to test to get child info
//for(temp = my_buffer.readLine(); temp != "Location" && temp != null; groupCount++, childrenCount++){
//children[groupCount][childrenCount] = temp;
//}
temp = my_buffer.readLine();
}
my_buffer.close();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
Log.e("IO EXCEPTION", "Exception occured in MyExpandableListAdapter:" + e.toString());
}
return groups;
}
場合 'equals'は動作しませんか? – EboMike
これは(たぶん)役立つでしょう:http://stackoverflow.com/questions/4210713/equal-and-equalsignorecase-return-false-for-equal-strings – MByD