我試過幾十種不同的組合,我不知道爲什麼這不起作用 - 它的邏輯是完全合理的。比較從捆綁到本地值的字符串
我從前一個活動中傳遞了一個包,它將來自微調控件的值存儲到一個字符串中。然後,我正在閱讀字符串,如果它與我指定的任何東西都是同等的 - 就此採取行動。
我已經將字符串直接打印到TextView中,以確保我獲得了預期的結果,而且我 - 但它仍然不會註冊。
TextView tv;
Bundle extras = getIntent().getExtras();
tv = (TextView) findViewById(R.id.textView2);
tv.append(extras.getString("pageNumber"));
tv = (TextView) findViewById(R.id.textView3);
int base = Integer.parseInt(extras.getString("pageNumber")) * 70;
tv.append(Integer.toString(base));
/* Here is where I'm editing */
tv = (TextView) findViewById(R.id.textView4);
String plat = extras.getString("platform");
if (plat == "Wordpress") tv.append("900");
我對微調陣列在我的strings.xml中定義和如下:
<string-array name="platform_array">
<item>None</item>
<item>Joomla</item>
<item>Wordpress</item>
<item>Drupal</item>
</string-array>
Hm,必須是Java特定的語法 - 我習慣C++。謝謝! –