[英]Navigation drawer in android fragment
I have created navigation drawer in a separate class and extended that activity to a fragment. 我在单独的类中创建了导航抽屉,并将该活动扩展为一个片段。 Navigation drawer is working fine in that fragment.
导航抽屉在该片段中工作正常。 And I am switching the content of the fragment using FragmentManager.
我正在使用FragmentManager切换片段的内容。
FragmentManager fragmentManager = getSupportFragmentManager();
if (savedInstanceState != null) {
if (savedInstanceState.containsKey("content")) {
String content = savedInstanceState.getString("content");
if (content.equals(FavoriteListFragment.ARG_ITEM_ID)) {
if (fragmentManager.findFragmentByTag(FavoriteListFragment.ARG_ITEM_ID) != null) {
setFragmentTitle(R.string.favorites);
contentFragment = fragmentManager
.findFragmentByTag(FavoriteListFragment.ARG_ITEM_ID);
}
}
}
if (fragmentManager.findFragmentByTag(ProductListFragment.ARG_ITEM_ID) != null) {
pdtListFragment = (ProductListFragment) fragmentManager
.findFragmentByTag(ProductListFragment.ARG_ITEM_ID);
contentFragment = pdtListFragment;
}
} else {
pdtListFragment = new ProductListFragment();
setFragmentTitle(R.string.app_name);
switchContent(pdtListFragment, ProductListFragment.ARG_ITEM_ID);
}
Navigation drawer is visible in ProductListFragment but on clicking FavoriteListFragment it is overlapped by that fragment. 导航抽屉在ProductListFragment中可见,但是在单击FavoriteListFragment时,该抽屉就会被该片段覆盖。 How to resolve that?
如何解决? I need to get the drawer in both ProductListFragment and FavoriteListFragment
我需要同时在ProductListFragment和FavoriteListFragment中获得抽屉
I would suggest you to use MaterialDrawer library by Mike Penz . 我建议您使用Mike Penz的 MaterialDrawer库。 Simple and powerful API.
简单而强大的API。 Just browse the samples to examine the lib.
只需浏览示例以检查lib。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.