I follow example from here using section listview
http://lalit3686.blogspot.com/2012/05/sectionadapter.html
But how can I implement adapter.notifyDataSetChanged()?
Adding listener to update the listview data:
mListView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(SectionAdapterActivity.this, ""+position+"", Toast.LENGTH_SHORT).show();
test();
}
});
I’m adding new function only for change/update value (testing only):
public void test()
{
hashMap.clear();
for (int i = 0; i < 3; i++) {
hashMap.put("Mail", String.valueOf(1100 + i), 1);
}
for (int j = 0; j < 4; j++) {
hashMap.put("Case", String.valueOf(2100 + j), 15);
}
for (int j = 0; j < 5; j++) {
hashMap.put("File", String.valueOf(10000 + j), 20);
}
mListView.invalidate();
mListView.invalidateViews();
adapter.notifyDataSetChanged();
Log.e("dada", hashMap.toString());
}}
Seems like does not work, can anyone help?
I don’t understand exactly what you are trying to achieve with calling notifyDataSetChange().
this method is taking affect only when you change the logic data collection / database which been used by the adapter, after it has created already. in this situation – it would cause to update of the list with the new data
if that’s what you want to do, then to use it – what you need to do is simple: just call:
and that’s it :). nothing else.