Android Actionbar is not showing

时间:2015-11-12 10:45:22

标签: java android android-actionbar

After I created my own Style, my Actionbar doesnt appear.I'm using a Pageviewer with tabhost which is visible but my actionbar isn't.I think it is caused by my Styles.xml.I also tried to edit the theme with the Android theme Editor but it did not help.

This is my Styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Newme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="actionBarItemBackground">@drawable/selectable_background_newme</item>
    <item name="popupMenuStyle">@style/PopupMenu.Newme</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.Newme</item>
    <item name="actionBarTabStyle">@style/ActionBarTabStyle.Newme</item>
    <item name="actionDropDownStyle">@style/DropDownNav.Newme</item>
    <item name="actionBarStyle">@style/ActionBar.Solid.Newme</item>
    <item name="actionModeBackground">@drawable/cab_background_top_newme</item>
    <item name="actionModeSplitBackground">@drawable/cab_background_bottom_newme</item>
    <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Newme</item>           
    <item name="actionBarWidgetTheme">@style/Theme.Newme.Widget</item>

</style>

<style name="ActionBar.Solid.Newme" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
    <item name="background">@color/theme_color</item>
    <item name="backgroundStacked">@color/theme_color</item>
    <item name="backgroundSplit">@color/theme_color</item>
    <item name="progressBarStyle">@style/ProgressBar.Newme</item>
</style>

<style name="PopupMenu.Newme" parent="@style/Widget.AppCompat.PopupMenu">   
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_newme</item> 
</style>

<style name="DropDownListView.Newme" parent="@style/Widget.AppCompat.ListView.DropDown">
    <item name="android:listSelector">@drawable/selectable_background_newme</item>
</style>

<style name="ActionBarTabStyle.Newme" parent="@style/Widget.AppCompat.ActionBar.TabView">
    <item name="android:background">@drawable/tab_indicator_ab_newme</item>
</style>

<style name="DropDownNav.Newme" parent="@style/Widget.AppCompat.Spinner.DropDown.ActionBar">
    <item name="android:background">@drawable/spinner_background_ab_newme</item>
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_newme</item>
    <item name="android:dropDownSelector">@drawable/selectable_background_newme</item>
</style>

<style name="ProgressBar.Newme" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
    <item name="android:progressDrawable">@drawable/progress_horizontal_newme</item>
</style>

<style name="ActionButton.CloseMode.Newme" parent="@style/Widget.AppCompat.ActionButton.CloseMode">
    <item name="android:background">@drawable/btn_cab_done_newme</item>
</style> 

<style name="Theme.Newme.Widget" parent="@style/Theme.AppCompat">
    <item name="popupMenuStyle">@style/PopupMenu.Newme</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.Newme</item>
</style>

I hope some of you can help me.

EDIT:

Here is my Mainactivity:

package com.miguel.fitnessapp;

public class MainActivity extends FragmentActivity implements     OnTabChangeListener, OnPageChangeListener {

private TabsPagerAdapter mAdapter;
private ViewPager mViewPager;
private TabHost mTabHost;

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

    mViewPager = (ViewPager) findViewById(R.id.viewpager);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getWindow().setStatusBarColor(getResources().getColor(R.color.theme));
    }


    initialiseTabHost();
    mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
    // Fragments and ViewPager Initialization


    mViewPager.setAdapter(mAdapter);
    mViewPager.setOnPageChangeListener(MainActivity.this);
}


private static void AddTab(MainActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec) {
    tabSpec.setContent(new MyTabFactory(activity));
    tabHost.addTab(tabSpec);
}


public void onTabChanged(String tag) {
    int pos = this.mTabHost.getCurrentTab();
    this.mViewPager.setCurrentItem(pos);
}

@Override
public void onPageScrollStateChanged(int arg0) {
}

// Manages the Page changes, synchronizing it with Tabs
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
    int pos = this.mViewPager.getCurrentItem();
    this.mTabHost.setCurrentTab(pos);
}

@Override
public void onPageSelected(int arg0) {
}



private void initialiseTabHost() {
    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();


    MainActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Training").setIndicator("Training"));
    MainActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Ernährung").setIndicator("Ernährung"));
    MainActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Körper").setIndicator("Körper"));

    mTabHost.setOnTabChangedListener(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu items for use in the action bar
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu_edit, menu);
    return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle presses on the action bar items
    int id = item.getItemId();
    if (id == R.id.benutzer){

    }
    return super.onOptionsItemSelected(item);
}
}

0 个答案:

没有答案
相关问题