Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"setSupportActionBar(toolbar)" inside FragmentActivity?

How do I access setSupportActionBar(Toolbar toolbar) inside FragmentActivity? I can't access it inside FragmentActivity

toolbar = (Toolbar) findViewById(R.id.search_bar); setSupportActionBar( toolbar); 
like image 854
katwal-Dipak Avatar asked Feb 27 '15 08:02

katwal-Dipak


People also ask

Can a fragment have toolbar?

When using fragments, the app bar can be implemented as an ActionBar that is owned by the host activity or a toolbar within your fragment's layout. Ownership of the app bar varies depending on the needs of your app.

How do I get the activity toolbar in fragment?

getActivity()). getToolbar(); will be the right answer!! for getting the Toolbar in fragment!!

What is the purpose of Setsupportactionbar?

Asking for help, clarification, or responding to other answers.

What is toolbar Android?

In Android applications, Toolbar is a kind of ViewGroup that can be placed in the XML layouts of an activity. It was introduced by the Google Android team during the release of Android Lollipop(API 21). The Toolbar is basically the advanced successor of the ActionBar.


1 Answers

With the latest version of the support library you should make your Activity extend AppCompatActivity as ActionBarActivity has been deprecated.

It provides the same functionality as your ActionBarActivity previously did. You shouldn't need to make any further changes.

like image 151
Zapnologica Avatar answered Sep 22 '22 00:09

Zapnologica