Fragment should contain a toolbar, tabview and viewpager. toolbar from android.support.v7.widget.Toolbar library.

The activity into which the fragment is loaded contains only FrameLayout.

Tell me how to get the toolbar correctly and configure it in the fragment class?

  • Place a Toolbar in the fragment markup, then refer to it. - Yuriy SPb

1 answer 1

Create a ToolBar in activation.

http://javatechig.com/android/android-lollipop-toolbar-example

To access it from the fragment - getActivity (). GetSupportActionBar ();

  • And you can not make the ToolBar markup only in the layoute of the fragment, and then load this fragment into the Activity, which contains only the FrameLayout, and, respectively, then configure the ToolBar as necessary? It's just that I need to load several fragments and in each case the ToolBar is different. - Kalyashov Gregory
  • Try to create a toolbar as written in the lesson, but not in activation, but directly in the fragment, then set it to activate - getActivity (). SetSupportActionBar (); - Joe Silent
  • thanks, everything worked out) - Kalyashov Gregory
  • Only now ActionBarDrawerToggle is gone ( - Kalyashov Gregory
  • How did you install ActionBarDrawerToggle on ActionBar ? - Joe Silent