Oleg
Oleg

Reputation: 41

Create a different toolBars on different Fragments in one Activity

I have some task to create one activity whith includes two Fragments.On first Fragment include the simple toolBar with title and one custom button in the end(ImageView), on second I need button back,search with functional, and title.What is the best way implement this??Create toolBar in activity and change it dependent on the status or create toolbar in each Fragment??if someone already has such realization in code I will be grateful for his browsing.

Thanks

Upvotes: 4

Views: 3038

Answers (1)

Ridcully
Ridcully

Reputation: 23665

In your fragment(s), in onCreate() call setHasOptionsMenu() and implement the onCreateOptionsMenu() method.

Also see the 'Adding items to the Actionbar' section of http://developer.android.com/guide/components/fragments.html

Upvotes: 1

Related Questions