这是我的代码,Eclipse没有显示任何错误,程序正常工作,但是它根本不完全做我想要的:)
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_dangeric”,则应该有“ is_ok”图像。
现在,显示没有if-comparemison的图像完美效果。
如果我将标签打印为字符串,它可以工作,它将正确打印“危险”或“ not_dangeric”,具体取决于标签。
但是,如果有如上图所示的if-comparemison,则不会发生任何图像。
请任何人帮助!=)