diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 35f085e7b3..7dc39960b6 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -88,7 +88,12 @@ public class OCFileListFragment extends ExtendedListFragment private OCFile mTargetFile; - + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setHasOptionsMenu(true); + } + /** * {@inheritDoc} */ @@ -213,6 +218,11 @@ public class OCFileListFragment extends ExtendedListFragment outState.putParcelable(KEY_FILE, mFile); } + @Override + public void onPrepareOptionsMenu (Menu menu) { + changeGridIcon(menu); // this is enough if the option stays out of the action bar + } + /** * Call this, when the user presses the up button. * @@ -340,7 +350,6 @@ public class OCFileListFragment extends ExtendedListFragment // String.format(mContext.getString(R.string.subject_token), // getClient().getCredentials().getUsername(), file.getFileName())); - changeGridIcon(menu, targetFile); } } @@ -640,9 +649,9 @@ public class OCFileListFragment extends ExtendedListFragment } } - private void changeGridIcon(ContextMenu menu, OCFile targetFile){ + private void changeGridIcon(Menu menu){ MenuItem menuItem = menu.findItem(R.id.action_switch_view); - if (isGridViewPreferred(targetFile)){ + if (isGridViewPreferred(mFile)){ menuItem.setTitle(getString(R.string.action_switch_list_view)); menuItem.setIcon(R.drawable.ic_view_list); } else {