Update Actionbar Dropdown Properly
Solution 1:
Try using invalidateOptionsMenu() method
@Override
public void onBackPressed() {
getActivity().invalidateOptionsMenu();
}
Description of invalidateOptionsMenu(): http://developer.android.com/reference/android/app/Activity.html#invalidateOptionsMenu()
Solution 2:
I finally figured it out! (And yes it was a simple solution, still lot's of learning to do in Android).
So in my original post I always set actionBar.setSelectedNavigationItem(int) in the onCreate method of the activities. However, when pressing the back button, the activity doesn't go through onCreate but it goes through onRestart(), onStart(), and onResume(), and that's why the dropdown list wasn't getting updated. In order to solve my problem, I simply call actionBar.setSelectedNavigationItem(int) inside of onResume() and now pressing the back button DOES update the dropdown :).
Post a Comment for "Update Actionbar Dropdown Properly"