Android的ImageView的setvisibility
问题描述:
我想改变的ImageView的知名度,如果值= X
i want to change visibility of imageview if value= x
但我对日食的错误消息。
but i have error message on eclipse.
下面是我的Java的一部分
here is part of my java
if (success == 1) {
// products found
// Getting Array of Products
products = json.getJSONArray(TAG_PRODUCTS);
// looping through All Products
for (int i = 0; i < products.length(); i++) {
JSONObject c = products.getJSONObject(i);
// Storing each json item in variable
String id = c.getString(TAG_PID);
String name = c.getString(TAG_NAME);
String price = c.getString(TAG_PRICE);
String cu = c.getString(TAG_CU);
/////////////
///HERE THE BUG////
if (cu == "1"){
cu = "oui";
}
else {
ImageView image_A_wrong = (ImageView) findViewById(R.id.imageView1);
image_A_wrong.setVisibility(View.GONE);
}
和我在这里的xml文件
and here my xml file
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/quo100px"
android:visibility="gone" />
TKS您的帮助
tks advance for your help
答
使用 cu.equals(1)
,而不是铜== 1
键,你会没事的。
Use cu.equals("1")
rather than cu == "1"
and you'll be fine