0

I would like to have onPrepareOptionsMenu called every time a user clicks the overflow menu button (3 dots). From what I understand, on HC+ devices the menu is considered to always be showing, so onPrepareOptionsMenu will only be called the first time, or after invalidateMenuOptions is called. My question is, how do I call invalidateMenuOptions on an overflow button click? This is in a Fragment that is in an ActionBarCompat ActionBarActivity.

4

1 回答 1

1

您可以像这样简单地从 Fragment 调用 invalidateOptionsMenu:

getActivity().invalidateOptionsMenu();

但是我不确定如果在单击溢出按钮时调用它会发生什么。这很可能会扰乱 ActionBar 的行为,并且可能不值得您花时间来完成这项工作。

此外,您还必须考虑并非所有设备都以这种方式实际显示溢出菜单。例如,所有带有菜单按钮的设备 - 几乎所有三星设备和许多旧设备 - 根本不显示溢出菜单按钮。因此,您可能应该重新考虑并尝试以其他方式解决您的问题。

于 2013-11-06T00:25:55.803 回答