我使用https://github.com/roughike/BottomBar模块在应用程序中实现底部栏功能
问题是我在每个活动中都包含一个 BottomBar 布局
有什么方法可以让我只使用一次 BottomBar,因此我可以在整个应用程序中使用该单个 BottomBar?
我使用https://github.com/roughike/BottomBar模块在应用程序中实现底部栏功能
问题是我在每个活动中都包含一个 BottomBar 布局
有什么方法可以让我只使用一次 BottomBar,因此我可以在整个应用程序中使用该单个 BottomBar?
看看这个库。它适用于您正在使用的 BottomBar 库。基本上,您将不得不使用片段而不是活动。因此,您只需在主活动中包含您的 BottomBar 布局。
您应该使用25.0.0版中添加的 BottomNavigationView
我找到了一个在整个 Applicaiton 中使用单个 BottomBar 的最佳解决方案我创建了单个 Activity,即MainActivity和其余所有Fragments
通常,当我们用另一个片段替换片段时,我们无法获得我在下面代码中编写的那个解决方案的先前片段
FragmentManager fm;
FragmentTransaction fragmentTransaction;
public ProductListAdapter(Context context, List<ProductItem> items, FragmentManager fm) {
super(context, 0, items);
this.fm = fm;
fragmentTransaction = fm.beginTransaction();
layoutInflater = LayoutInflater.from(context);
}
btnProductMainViewMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fragmentTransaction.setCustomAnimations(android.R.anim.fade_in,
android.R.anim.fade_out);
fragmentTransaction.replace(R.id.frame, new ProductDetailFragment());
**fragmentTransaction.addToBackStack(null);** // with this line you can back to previous fragment
fragmentTransaction.commit();
}
});