這裏是我的代碼,Eclipse不顯示任何錯誤,程序工作正常,但它根本沒有做我想要什麼:)比較不正常工作的android
View image_view_danger_rate = (ImageView) findViewById(R.id.origin);
View image_view_origin = (ImageView) findViewById(R.id.danger_rate);
String entry_tag = (String) descriptionResultView.findViewById(resID).getTag();
String dangerous = "dangerous";
String not_dangerous = "not_dangerous";
if (entry_tag == dangerous) {
image_view_danger_rate.setBackgroundResource(R.drawable.attention);
}else if (entry_tag == not_dangerous) {
image_view_danger_rate.setBackgroundResource(R.drawable.its_ok);
image_view_origin.setBackgroundResource(R.drawable.artificial);
}
的應用程序應該在兩個圖像之間進行選擇以在屏幕上彈出,具體取決於存儲在xml文件中的標記。 所以,如果標籤說「危險」,那麼應該顯示「注意力」 - 圖像。 如果標籤顯示「not_dangerous」,應該有「its_ok」圖像。
現在,沒有if-comparison的情況下顯示圖像完美地工作。
如果我打印出標籤爲字符串,它的工作原理是,根據標籤打印正確的「危險」或「不危險」。
但是,如果有如上所示的if-comparison,則什麼都不會發生,不會顯示圖像。
請人幫助!=)
對於精心製作和完整的問題+1。 – Marcelo
此網站上詢問此問題的次數超過了我的意願。請使用搜索功能。 – Woot4Moo
@ Woot4Moo複製不是必不可少的。 http://blog.stackoverflow.com/2010/11/dr-strangedupe-or-how-i-learned-to-stop-worrying-and-love-duplication/ – Marcelo