0

I wanna grouping my data such as an schedule by date or week where i display in listview. I hope the result like this :

Listview display that i want

here my activity to show the data based on json parse :

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tampil_semua_pgw);
    listView = (ListView) findViewById(R.id.listView);
    listView.setOnItemClickListener(this);
    getJSON();
}
private void showEmployee(){
    JSONObject jsonObject = null;
    ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String, String>>();
    try {
        jsonObject = new JSONObject(JSON_STRING);
        JSONArray result = jsonObject.getJSONArray(konfigurasi.TAG_JSON_ARRAY);

        for(int i = 0; i<result.length(); i++){
            JSONObject jo = result.getJSONObject(i);
            String id = jo.getString(konfigurasi.TAG_ID);
            String nama = jo.getString(konfigurasi.TAG_NAMA);
            String pyg = jo.getString(konfigurasi.TAG_PENYELENGGARA);
            String tmpt = jo.getString(konfigurasi.TAG_TEMPAT);
            String tgl = jo.getString(konfigurasi.TAG_TGL);
            String jam = jo.getString(konfigurasi.TAG_JAM);
            String email = jo.getString(konfigurasi.TAG_EMAIL);

            HashMap<String,String> employees = new HashMap<>();
            employees.put(konfigurasi.TAG_ID,id);
            employees.put(konfigurasi.TAG_NAMA,nama);
            employees.put(konfigurasi.TAG_PENYELENGGARA,pyg);
            employees.put(konfigurasi.TAG_TEMPAT,tmpt);
            employees.put(konfigurasi.TAG_TGL,tgl);
            employees.put(konfigurasi.TAG_JAM,jam);
            employees.put(konfigurasi.TAG_EMAIL,email);
            list.add(employees);
        }

    } catch (JSONException e) {
        e.printStackTrace();
    }
    ListAdapter adapter = new MySimpleArrayAdapter(this, list);
    listView.setAdapter(adapter);
}

And here my custom adapter : enter image description here

  • try this https://stackoverflow.com/questions/32867823/how-to-show-date-in-between-conversation-in-recyclerview-or-in-listview/44843070#44843070 – akhilesh0707 Sep 28 '17 at 09:51
  • Use ExpandableListView Example is in link https://www.journaldev.com/9942/android-expandablelistview-example-tutorial –  Sep 28 '17 at 10:03

0 Answers0