I have this activity in a tabhost and I need to reload it when I change to another tab, and came back to this activity, for my listview can refresh with the new items. Can anybody tell me how can I do this.
Here is my favorites activity:
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.favorites);
initialize();
}
private void initialize(){
list=(ListView) findViewById(R.id.fav_listView1);
back=(ImageView) findViewById(R.id.favorites_back_img);
back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
helper=new DatabaseHelper(this);
helper.openDB();
adapter=new AlbumLazyAdapter(this, helper.getAllFavorites(), this);
list.setAdapter(adapter);
}
@Override
protected void onPause() {
super.onPause();
adapter.notifyDataSetChanged();
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
adapter.notifyDataSetChanged();
}
call initialize()
method in onResume()
.