mardi 3 mars 2015

Decide the clickable status of check box according to json response

I have a check box in my application and it should be clickable when mayoBase returns true and its shouldn't be clickable when mayoBase returns false. I have tried the below mentioned code, but it crashes. I have attached my logcat, how can I overcome this. Any help will be appreciated.



@Override
public void onTaskCompleted(JSONArray responseJson) {

try {
List<String> mayoBase = 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"));
mayoBase.add(object.getString("IsMayoBaseAvailable"));

}

String strIsVag = mayoBase.get(i); //line 392
mayoBaseCB = (CheckBox) findViewById(R.id.ch_mayobase);
if (strIsVag.contains("true")) {
mayoBaseCB.setEnabled(true);
} else {
mayoBaseCB.setEnabled(false);
}


enter image description here


Aucun commentaire:

Enregistrer un commentaire