Reputation: 2073
I have a list view containing names.I am able to add those names to phones's contact list but the changes are not getting reflected in my list view untill I restart the application again.kindly help.thanks in advance. I have tried this but ain't working.
public void onPause(){
super.onPause();
finish();
}
Upvotes: 0
Views: 190
Reputation: 19250
Repopulate your listview in onResume() of your activity,so that changes will appear in your listview after you will add new data.
public void onResume(){
super.onResume();
populateListview();
}
public void populateListview()
{
//reset adapter
listview.setAdapter(adapter);
}
Upvotes: 0
Reputation: 9520
What you need to do in this case is whenever you add the list item you need to set the Adapter
again. or you can call the notifyDatasetchanged()
method.
Upvotes: 1
Reputation: 509
Try to do this.Hope this will solve your problem.
public void onPause(){
super.onPause();
Intent intent = getIntent();
finish();
startActivity(intent);
}
Or
//lv is your ListView
lv.setAdapter(adapter);
lv.invalidateViews();
after the contact list is updated.
Upvotes: 0