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);
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);
AppCompatActivity
extendsFragmentActivity
you can use
AppCompatActivity
insteadUse this methods your activity need to extend ActionBarActivity instead of FragmentActivity
Hope it helps
If you want your
ViewPager
to add fragments, you can extendAppCompatActivity
, it also works. (Often, we extendFragmentActivity
, but after thatsetSupportActionBar
( toolbar) doesn't work) So, we can extendAppCompatActivity
instead of extendingFragmentActivity
.If your class extends
FragmentActivity
and if the toolbar is inside the layout you used, it will be set by default. To access it simply do
(Toolbar) findViewById(R.id.toolbar)
You can just extend your class with
AppCompatActivity
, sinceAppCompatActivity extends FragmentActivity
internally. Also,ActionBarActivity
is deprecated.For
FragmenrtActivity
, you should look intoFragmentTabHost
, and to add tabs simply: