Here is the code:
@Override
public void onResume() {
super.onResume();
adapter.notifyDataSetChanged();
Log.d("onResumeMethod", "It is called! :)");
}
}
I am using this to refresh list when anything is edited in the database. Unfortunately it is not working. Somewhere I read I should use requery but it is already deprecated. Any advice?
EDIT:
Tried already this, but did not help(unfortunately, because I was convinced it is gonna work):
@Override
public void onResume() {
super.onResume();
adapter = new ArrayAdapter<Friend>(this,
android.R.layout.simple_list_item_1, list);
this.getListView().setAdapter(adapter);
this.getListView().invalidate();
}
I found another problem: If I use back button (on emulator) to go back to desktop and try to turn on an application by clicking on a menu item it shows me this:
03-19 15:43:50.153: E/AndroidRuntime(7374): FATAL EXCEPTION: main
03-19 15:43:50.153: E/AndroidRuntime(7374): java.lang.RuntimeException: Unable to start
activity
ComponentInfo{com.example.birthdayreminder/com.example.birthdayreminder.MainActivity}:
java.lang.RuntimeException: Your content must have a ListView whose id attribute is
'android.R.id.list'
I faced this problem before so they adviced me to insert this to my xml:
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
</ListView>