Newbie question
I have a json file which contains multiple categories with the same name.
For example
{"long_description":"test",
"short_description":"test",
"category_name":"work",
"id":1},
{"long_description":"test2",
"short_description":"test2",
"category_name":"work",
"id":2},
{"long_description":"test",
"short_description":"test",
"category_name":"home",
"id":3}
My question is how to create list view with sections (category name) I'm using a custom adapter heres my loop
try {
JSONObject responseObject = new JSONObject(response);
JSONObject itemsObject = responseObject.getJSONObject("items");
Iterator<?> keysIterator = itemsObject.keys();
while(keysIterator.hasNext()) {
String keyString = (String)keysIterator.next();
JSONObject coupon = couponsObject.getJSONObject(keyString);
Item item = new Item();
item.setLongDescription(item.getString("long_description"));
itemList.add(item);
}
} catch (Exception e) {
e.printStackTrace();
}
adapter.notifyDataSetChanged();
Use below links very good examples of listview with header.
http://applidium.github.io/HeaderListView/
http://javatechig.com/android/listview-with-section-header-in-android
http://sunil-android.blogspot.in/2013/08/section-header-listview-in-android.html
in given below code just update data with your header and list item this example is simplest
CustomAdapter.java
SectionListView.java