Hi,
I'm trying to access a public JSONArray variable from another object:
Snippets from the planner object:
public JSONArray plannedItems;
String result = queryRESTurl(url);
try{
JSONObject json = new JSONObject(result);
JSONArray nameArray = json.names();
if (json.toJSONArray(nameArray).length() > 0) {
plannedItems = json.toJSONArray(nameArray);
return true;
} else {
Log.i("refreshPlanner", "The json array was empty.");
return false;
}
}
The actual JSON response:
{"acts":1,"id":"184424","descr":"bed: lakens afdoen","start_minute":
1371,"end_minute":1395,"picto":"images\/pictos\/bed afdoen.png"}
How can I loop through or access these results? I prefer to use it as
a hash.
As said, I am accessing the plannedItems variable from a different
object.
I've googled around for it, but only am getting some examples that I
cannot get working.
This is what I came up with; unfortunately it makes the app crash
horribly:
private void PopulatePlanner() {
if (plan.plannedItems.length() > 0) {
TextView descr = (TextView)findViewById
(R.id.ActivityDescription);
try {
descr.setText(plan.plannedItems.getString(2));
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Thanks,
Ger
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en