0
我有3个片段:A, B, C
和ActionItem
调用Filters
。这些Filters
只有在分别可见片段A
时才可见。ActionItem出现在方向更改
所以我躲Filters
时B
或C
被取代了A
和它们恢复回来时A
被替换回来。
工作正常,除非我改变屏幕的方向。之后变成可见的Filters
。
有什么我想:
其中代表片段导航覆盖活动我检查可见Fragment
,如果它B
或C
我hideActionFilters()
:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
....//other logic
//check if backStack empty
if (getSupportFragmentManager().getBackStackEntryCount() != 0) {
//check top fragment by position and name in backstack
//LessonsFragment - B; SingleLessonFragment - C
if (getTopFragment().getClass().getName().equals(LessonsFragment.class.getName()) ||
getTopFragment().getClass().getName().equals(SingleLessonFragment.class.getName())) {
hideActionFilterItem();
}
}
这不工作。 方法hideActionItem()
:
private void hideActionFilterItem() {
View menuItemView = findViewById(R.id.action_filters);
if (menuItemView != null) {
menuItemView.setVisibility(View.GONE);
}
}
试过调试,运行hideActionItem()
但ActionItem
仍然可见。
我也试图隐藏在onPause()
;在片段B
和C
的onConfogChanged()
中。
可能有人有这样的问题。请帮忙。
P.S.请告诉我是否需要更多代码。谢谢