android - Two Toolbars -> two menus -> from fragment -


i not know, how solve problem.

so... have 2 toolbars in 1 activity. change 1 toolbar depending on fragment. (below)

fragmentcategory.java

 @override public void oncreateoptionsmenu(final menu menu, menuinflater inflater) {     if(category_id == -1){               inflater.inflate(r.menu.menu_fragment_category, menu);         super.oncreateoptionsmenu(menu, inflater);     }else if(category_id == -2){       }else if(category_id == -3) {          inflater.inflate(r.menu.menu_fragment_category2, menu);         super.oncreateoptionsmenu(menu, inflater); }}   @override public boolean onoptionsitemselected(menuitem item) {     if (item.getitemid() == r.id.action_refresh) {         actionrefresh();     }     if (item.getitemid() == r.id.action_map) {         intent = new intent(getactivity().getapplicationcontext(), activitymaps.class);         startactivity(i);     }      if (item.getitemid() == r.id.action_upload) {      mymethod();         }     if (item.getitemid() == r.id.action_filter) {     dialogcategory();      }     return super.onoptionsitemselected(item); } 

mainactivity.java

    private void inittoolbar(){     toolbar = (toolbar) findviewbyid(r.id.toolbar);     setsupportactionbar(toolbar);     actionbar = getsupportactionbar();     actionbar.setdisplayhomeasupenabled(true);     actionbar.sethomebuttonenabled(true);     tools.setactionbarcolor(this, actionbar); } 

this works perfectly, want add second toolbar , approach him fragmentcategory.java too.

i need 1 button, ideal "navigationicon" (left side), menu item okay too.

second_toolbar_menu.xml

<item     android:id="@+id/action_filter"     android:icon="@drawable/ic_filter_212121_10"     android:tint="@color/mainblack"     android:title="filters"     app:showasaction="always"     /> 

part of activity_main.xml

    <android.support.design.widget.coordinatorlayout         android:layout_width="match_parent"         android:layout_height="match_parent">          <android.support.design.widget.appbarlayout             android:id="@+id/appbar"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:theme="@style/themeoverlay.appcompat.dark.actionbar">              <framelayout                 android:layout_width="match_parent"                 android:layout_height="?attr/actionbarsize"                 app:layout_scrollflags="scroll|enteralways|snap">                  <include layout="@layout/toolbar" />              </framelayout>              <view                 android:layout_width="match_parent"                 android:layout_height="1px"                 android:background="@color/view_background"                 app:layout_scrollflags="scroll|enteralways|snap"/>              <framelayout                 android:layout_width="match_parent"                 android:layout_height="?attr/actionbarsize"                 app:layout_scrollflags="scroll|enteralways|snap">                 <include layout="@layout/toolbar_filters" />             </framelayout>          </android.support.design.widget.appbarlayout>          <framelayout             android:id="@+id/frame_content"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:layout_below="@+id/appbar"             app:layout_behavior="@string/appbar_scrolling_view_behavior" />      </android.support.design.widget.coordinatorlayout> 

can me, please? :) thank guys !!!


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -