Hi,
I have a listView which loads records either sorted by distance or sorted by Name and the type of records that gets loaded is decided by a button click. I get list from db that is sorted by distance and i wrote two adapter class to display, one is SimpleAdapter and other is customized adapter implementing SectionIndexer to display order by Name.By default i call to load records ordered by Name and the indexer works fine and when i click order by Distance ,the records displays by distance but the indexer doesn't vanish and the log statements shows this.In this case how to refresh the listView.The code i am using is as below
findViewById(R.id.by_distance).setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
upDateListByDistance();
}
});
finddViewById(R.id.by_name).setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
upDateListByName();
}
});
....
....
public void upDateListByDistance(){
mSchedule = new SimpleAdapter(A.this, orderByDistaceList, R.layout.rownew,
new String[] {"name", "address", "dist"}, new int[] {R.id.one, R.id.two, R.id.three});
getListView().setAdapter(mSchedule);
}
public void upDateListByName(){
getListView().setFastScrollEnabled(true);
MyAdapter adapter = new MyAdapter(getApplicationContext(),arrangedByNameList,nameslist);
getView().setAdapter(adapter);
}
private class MyAdapter extends BaseAdapter implements SectionIndexer {
......
......
......
@Override
public int getPositionForSection(int section) {
Lod.v(TAG,"still iam displaying");
.....
}
I will glad to know whether this kind of approach is correct way of coding ,if yes then is there is any way to refresh my listView ,I tried using invalidate on list view but no effect.
ganesh