如何,我们可以在整个应用程序使用单BottomBar像动作条中的Android

问题描述:

我用https://github.com/roughike/BottomBar模块用于实现应用如何,我们可以在整个应用程序使用单BottomBar像动作条中的Android

问题bottombar特征就是,我包括在每个活动

一个BottomBar布局有什么办法我如何才能在一次中使用BottomBar,因此我可以在整个应用程序中使用该单个BottomBar?

看看这个library。它适用于您正在使用的BottomBar库。基本上,你将不得不使用片段而不是活动。所以你只需要将你的BottomBar布局包含在主要活动中。

+0

我在** activity_main.xml **中使用bottomBar,并在MainActivity中使用4个不同的片段。在泰国,我有一个** ProductFragment ** 在这一点上,当我点击_View More_ Button时,它将**重定向到** ProductDetailsActivity.java **。那么如何使用单个BottomBar @Ander去 –

+1

在您的应用程序中创建只有一个单独的活动休息都应该是该框架 –

+0

我无法获得ProductFragment,而我用ProductDetailFragment替换时,我单击ActionBar上的后退箭头按钮。 您是否有任何解决方案该问题@ Bharatsingh –

您应该使用它在版本25.0.0

+0

如何在整个应用程序中使用单个BottomNavigationView? –

+0

它更好地在viewpager中使用片段,这将允许您始终保持botttomnavview constatnr,您可以参考[link](http://droidmentor.com/bottomnavigationview-with-viewpager-android/)以获取更多详细信息 –

我发现单BottomBar使用的一个最好的解决方案在整个应用程序了 添加BottomNavigationView我创建单一的活动,是MainActivity和其余全部片段的

通常,当我们与另一个片段取代片段,我们不能让以前的片段,该解决方案我写下面的代码

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(); 
       } 
      });