I am showing JSON data in listview. I am parsing JSON array and getting 3 values.
Now I want to show header as those event are on 8/1/2013 are shown under header name as date "8/1/2013" and those entries on different date shown under their respective section with proper date
Piece of my code:
ArrayList<RidesValue> alrides = new ArrayList<RidesValue>();
List<String> rides = new ArrayList<String>();
ListView listView;
public class RidesValue
{
String time;
String place;
String address;
}
public void displaylist(String time, String place, String address)
{
RidesValue rideval = new RidesValue();
rideval.time = time;
rideval.place = place;
rideval.address = address;
alrides.add(rideval);
rides.add("Time: " + time + "\nPlace: " + place
+ "\nAddress: " + address);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.simplelist, rides);
listView = (ListView) findViewById(R.id.lvride);
listView.setAdapter(adapter);
}
I call displaylist method every i parse a single array from json array:
JSONArray jarray = new JSONArray(savedresponse);
if(jarray.length() == 0)
Toast.makeText(this, "Sorry no rides found", Toast.LENGTH_SHORT).show();
Log.i("JSON ARRAY",String.valueOf(jarray));
for(int i=0; i<jarray.length(); i++)
{
JSONObject value = jarray.getJSONObject(i);
time = value.getString("Time");
place = value.getString("Place");
address = value.getString("Address");
displaylist(time, place,address);
}
So question is where and how i put n what code so group entries by under date as header in list view
Your question was not so clear. But as much I understood i think you can go for Expandable ListView.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.