Theme.AppCompat.Light gets Actionbar returns null in API 11

Theme.AppCompat.Light get Actionbar returns null in API 11.

I have the following code:

<uses-sdk
        android:maxSdkVersion="19"
        android:minSdkVersion="9"
        android:targetSdkVersion="19" />

     <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/Theme.AppCompat.Light" >

Here is the action bar call in action:

int currentVersionOfAPI = android.os.Build.VERSION.SDK_INT;
        if (currentVersionOfAPI < android.os.Build.VERSION_CODES.HONEYCOMB) {
            setContentView(R.layout.activity_gameaction);
            android.support.v7.app.ActionBar ab = this.getSupportActionBar();
            if (ab != null) {
                ab.setHomeButtonEnabled(true);
                ab.setTitle(GD.getName());
            }
        } else {
            this.requestWindowFeature(Window.FEATURE_ACTION_BAR);
            setContentView(R.layout.activity_gameaction);
            ActionBar ab = this.getActionBar();
            if (ab != null) {
                ab.setDisplayHomeAsUpEnabled(true);
                ab.setTitle(GD.getName());
            }

I am running Android 3.0 emulator, and getActionBar () returns null.

Any ideas on how to solve this problem?

+3
source share
1 answer

I had the same problem with the application, it works fine for all devices except the galaxy tabs with Android 3.x, and my application is in the store, so the pressure was too much to fix it, and this is how I did it:

1.Use the -v11 values ​​with the correct style that shows the name and action bar.

2. , SetHomeButtonEnabled(), Honeycomb.

3. setContentView (ActionBar):

if(android.os.Build.VERSION.SDK_INT >= 11 && android.os.Build.VERSION.SDK_INT <=13) 
        { 
            getWindow().requestFeature(Window.FEATURE_ACTION_BAR); 
        } 

Galaxy Tab 10 H 3.2

0

All Articles