Error :java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

Error :java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

<activity
    android:name="com.luckyxmobile.timers4meplus.activity.WidgetConfigActivity"
    android:theme="@style/Theme.PageIndicator.Dark">
    <intent-filter>
        <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />

        <category android:name="com.jakewharton.android.viewpagerindicator.sample.SAMPLE" />
    </intent-filter>
</activity>


<style name="Theme.PageIndicator.Dark" parent="android:Theme">
    <item name="tpi_tabPadding">12dp</item>
    <item name="tpi_tabRipple">@style/DarkTabRippleStyle</item>
    <item name="tpi_indicatorHeight">3dp</item>
    <item name="tpi_indicatorColor">@color/colorPrimary</item>
    <item name="android:textAppearance">@style/DarkTabTextAppearance</item>
    <item name="android:background">@color/colorAccent</item>
    <item name="tpi_mode">scroll</item>
</style>

上面是主题,style.When我是运行应用,显示这个错误。我想也许应该 "Theme.AppCompat" 而不是 "android:Theme",但不确定!

你的 logcat 抛出什么

Error :java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

我猜,你需要扩展 AppCompatActivity

public class WidgetConfigActivity extends AppCompatActivity {
  // ...
}

AppCompatActivity is from the appcompat-v7 library. Principally, this offers a backport of the action bar. Since the native action bar was added in API Level 11, you do not need AppCompatActivity for that. However, current versions of appcompat-v7 also add a limited backport of the Material Design aesthetic, in terms of the action bar and various widgets.

您可以使用 Theme.AppCompat 而不是 android:Theme