How to refresh a page of activity in android? The page contains a Listview and a Gridview, I want to refresh only the Listeview.
thank you
How to refresh a page of activity in android? The page contains a Listview and a Gridview, I want to refresh only the Listeview.
thank you
There is no specific method for such operation, However you can achieve this by coding, with the help of Hanlder & Runnable Class.
Look at this code,
Handler handler = new Handler();
Runnable activityRefresh;
activityRefresh = new Runable() {
// Do something
handler.postDelayed(activityRefresh, 5000);
}
handler.post(activityRefresh);
You should move all the code that loads and sets the date on your ListView to a different method, and when you want to refresh only the ListView you can call your method again.
If your ListView adapter doesn't change, then you can simply modify the data within the adapter however you want, and then call listView.notifyDataSetChanged()
to visually update it.
To Refresh the Listview Call notifyDataSetChanged() on your Adapter.
u can look at this also.it may helpfull link