Skip to content

Instantly share code, notes, and snippets.

@aemxn
Created January 11, 2014 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aemxn/8374109 to your computer and use it in GitHub Desktop.
Save aemxn/8374109 to your computer and use it in GitHub Desktop.
@Override
protected void onPostExecute(String json) {
try {
categories = new JSONArray(json);
if (categories != null) {
// looping through All albums
for (int i = 0; i < categories.length(); i++) {
JSONObject c = categories.getJSONObject(i);
// Storing each json item values in variable
String id = c.getString(TAG_ID);
String name = c.getString(TAG_NAME);
String songs_count = c.getString(TAG_CATEGORIES_COUNT);
String category_logo = c.getString(TAG_CATEGORIES_LOGO);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(TAG_ID, id);
map.put(TAG_NAME, name);
map.put(TAG_CATEGORIES_COUNT, songs_count);
map.put(TAG_CATEGORIES_LOGO, category_logo);
// adding HashList to ArrayList
categoryList.add(map);
}
mAdapter = new CategoryListAdapter(CategoryActivity.this, categoryList);
getListView().setAdapter(mAdapter);
pDialog.dismiss();
} else {
Log.d("Categories: ", "null");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment