Android - ActionBar pre Honeycomb

瘦欲@ 提交于 2019-12-13 03:40:05

问题


Good evening,

i hope somebody could help me.

Im developing a app where i use the action bar from the support library for pre 3.0-devices, but i have the problem, that espacially on the pre 3.0-devices no action bar is showing. When i use a device, which is higher then 3.0 it works fine.

I've followed these tutorial: http://developer.android.com/guide/topics/ui/actionbar.html#Adding

So my "main activity", which handles the action bar, extends from "ActionBarActivity".

At these moment i figured out, that my tabs the undoubted cause.

My code looks like this:

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_hauptmenue_extended);

    try {
        Log.d("test", "Set ActionBar...");

        actionBar = getSupportActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.show();

        Tab tabB = actionBar.newTab();
        tabB.setText("Home");
        tabB.setIcon(R.drawable.icon_home);
        tabB.setTabListener(new TabListener<Startmenue_activity>(this,
                "Start", Startmenue_activity.class));
        actionBar.addTab(tabB);

        Tab tabA = actionBar.newTab();
        tabA.setText("");
        tabA.setIcon(R.drawable.icon_nachrichten_sel);
        tabA.setTabListener(new TabListener<Nachrichten_activity>(this,
                "Nachrichten", Nachrichten_activity.class));
        actionBar.addTab(tabA);

        Tab tabC = actionBar.newTab();
        tabC.setText("");
        tabC.setIcon(R.drawable.icon_favoriten);
        tabC.setTabListener(new TabListener<Favoriten_activity>(this,
                "Favoriten", Favoriten_activity.class));
        actionBar.addTab(tabC);

    } catch (Exception ex) {
        HelperClassAlertDialog.zeigeInfoDialog(this, "Error...",
                ex.getMessage(), "");
    }
}

When i delete the part of adding the tabs, the action bar works fine! But when i add the "tabs" again, no action bar is showing. But there are also no errors!

I really hope, somebody could help me. :(

Solution:

The following question and answer help me:

Tabs using android.support.v7.app.ActionBar

Or this:

ActionBar with support library and Fragments overlay content


回答1:


You have to use ActionBarSherlock. It's a library. Download it from this link. Here is a tutorial on how to use ActionBarSherlock.



来源:https://stackoverflow.com/questions/18857529/android-actionbar-pre-honeycomb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!