Reputation: 41
i want to change visibility of imageview if value= x
but i have error message on eclipse.
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);
}
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 advance for your help
Upvotes: 0
Views: 11195
Reputation: 744
For that you have to check if you are taking string for compression than use .equalsIgnoreCase("") function otherwise use == to compare .
Upvotes: 1
Reputation: 27748
You are checking for a String
in which case the .equals("your_constraint")
is used.
So, change this:
if (cu == "1") {
cu = "oui";
} else {
ImageView image_A_wrong = (ImageView) findViewById(R.id.imageView1);
image_A_wrong.setVisibility(View.GONE);
}
to this:
if (cu.equals("1")) {
cu = "oui";
} else {
ImageView image_A_wrong = (ImageView) findViewById(R.id.imageView1);
image_A_wrong.setVisibility(View.GONE);
}
Upvotes: 0