Android的ImageView的setvisibility [英] android imageview setvisibility
本文介绍了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
这篇关于Android的ImageView的setvisibility的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文