S
S
schoolboy2016-05-16 21:54:09
Android
schoolboy, 2016-05-16 21:54:09

How to add ActionBar or ToolBar to TabActivity?

there is an activity with tabs, but the actionbar is gone, how to add it to the tabactivity or the toolbar?

public class MainActivity extends TabActivity {
    public android.support.v7.widget.Toolbar toolbar;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TabHost tabHost = getTabHost();



        TabHost.TabSpec tabSpec;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
itdroid, 2016-05-18
@itdroid

TabActivity is deprecated (Deprecated since API level 13): https://developer.android.com/reference/android/ap...
I recommend using TabLayout from the Support design library: https://developer.android.com/reference/android/ su...
This is a regular ViewGroup: add it to the markup, find it in the code and initialize it.
This will help to avoid crutches with embedding Toolbar in TabActivity.
https://developer.android.com/topic/libraries/supp...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question