Error in app theme

Asked

Viewed 327 times

3

Guys I implemented some tabs in the app I’m developing with Fragments and had to use the theme of Appcompat but started giving this error:

Caused by: java.lang.Illegalstateexception: You need to use a Theme.Appcompat Theme (or Descendant) with this Activity.

Ai vou la na manifest e troco pro Appcompat, but then no more my actionbar appears in the app.

With Theme.Holo.Light the actionbar appears, but if I change because of the error it disappears.

And now?

Does anyone have any idea?


Manifest


<application
    android:allowBackup="true"
    android:icon="@mipmap/logo_bse_sem_fundo"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@android:style/Theme.Holo.Light">


    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Home_Activity" />
    <activity android:name=".BuscarClienteActivity" />
    <activity android:name=".InformacoesActivity"
        android:theme="@style/Theme.AppCompat.Light"></activity>
</application>


Styles


<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

  • put your manifest and your style.xml so we can see how you are, so it’s easier to see what you can do.

1 answer

0

To Activity that you’re trying to use the ActionBar class extension ActionBarActivity, in this case it is mandatory that you use the theme of AppCompat.

Make your class extend Activity Activity and leave the theme Theme.Holo.Light that will probably work.


@Edit

If you want to continue using the AppCompat, use a descending theme of Theme.AppCompat, Theme.AppCompat.Light or Theme.AppCompat.Light.DarkActionBar

  • So I solved this by adding android:Theme="@style/Theme.AppCompat.Light" to the Activity statement in the manifest. But because it is the theme of Appcompat the actionbar changes its appearance I wanted to keep the appearance of the actionbar as in the others that use the Holo theme. This Activity extends from Appcompatactivity. There’s a way I can use tabs without using Appcompat?

  • I’ve been changing everything from appCompat to android.app but my Adapter Fragmentstatepageradapter extends which apparently only exists in the support API. I couldn’t find it for android.app.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.