I have a grid in my application and when I select an item it load the items prospectively. I want to allow to select the check box only when isMayoBaseAvailable returns true.
This is the code I used, when I used this code and debug it work correctly, but when I run the application and check it always go inside the false (In all the items). Why does it happens?
I have shown my logcat as well.
@Override
public void onTaskCompleted(JSONArray responseJson) {
try {
List<String> crust = new ArrayList<String>();
List<String> descriptionHalf = new ArrayList<String>();
final List<String> description = new ArrayList<String>();
List<String> extraDescription = new ArrayList<String>();
for (int i = 0; i < responseJson.length(); ++i) {
JSONObject object = responseJson.getJSONObject(i);
if ((object.getString("MainCategoryID")).equals("1")) {
Log.i("Description ", object.getString("Description"));
descriptionHalf.add(object.getString("Description"));
Log.i("IsMayoBaseAvailable",
object.getString("IsMayoBaseAvailable"));
String isMayoBaseAvailable = object
.getString("IsMayoBaseAvailable");
mayoBaseCB = (CheckBox) findViewById(R.id.ch_mayobase);
if (isMayoBaseAvailable.contains("true")) {
mayoBaseCB.setEnabled(true);
} else {
mayoBaseCB.setEnabled(false);
}
JSONArray subMenuArray = object
.getJSONArray("SubMenuEntity");
for (int j = 0; j < subMenuArray.length(); ++j) {
JSONObject subMenuObject = subMenuArray
.getJSONObject(j);
Log.i("Crust", subMenuObject.getString("Crust"));
crust.add(subMenuObject.getString("Crust"));
Log.i("Description",
subMenuObject.getString("Description"));
description.add(subMenuObject.getString("Description"));
JSONArray extraItemEntityArray = subMenuObject
.getJSONArray("ExtraItemEntity");
for (int k = 0; k < extraItemEntityArray.length(); k++) {
JSONObject objectE = extraItemEntityArray
.getJSONObject(k);
if ((objectE.getString("Description")) != null
&& (objectE.getString("Type")).equals("E")) {
extraDescription.add(objectE
.getString("Description"));
}
}
}
// mayoBaseCB.setEnabled(false);
}
Logcat shows some items has isMayoBaseAvailable as true and some has as false.
Aucun commentaire:
Enregistrer un commentaire