AppCompat不支持当前的主题功能

时间:2015-06-03 15:26:40

标签: java android xml android-appcompat

以下是我的Android应用程序的代码。

<android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
         android:id="@+id/tb_main"
         android:layout_width="match_parent"
         android:layout_height="?attr/actionBarSize"
         app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
         app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
         tools:background="@color/orange" />

活动

Private void initView() {
             listView = (ListView) findViewById(R.id.lv_main);
             floatTitle = (TextView) findViewById(R.id.tv_main_title);
             toolbar = (Toolbar) findViewById(R.id.tb_main);
             setSupportActionBar(toolbar);
             getSupportActionBar().setDisplayHomeAsUpEnabled(true);
             }

我检查stackoverflow并且大多数人说这将解决问题,但我仍然面临问题我的Nexus 5 API 22 x86(模拟器)-Lollipop但在三星Galaxy Note 3(Kit Kat)上运行良好

我也设置为com.android.support:appcompat-v7:21.0.3

    <style name="FeedTheme" parent="Theme.AppCompat.Light">
     <item name="windowActionBar">false</item>
     <item name="android:windowNoTitle">true</item>
     </style>

错误

06-03 22:07:51.759  26306-26306/hopon.com.hopon E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{hopon.com.hopon/hopon.com.hopon.activity.FeedItemActivity}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2396)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2448)
            at android.app.ActivityThread.access$600(ActivityThread.java:173)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1392)
            at android.os.Handler.dispatchMessage(Handler.java:107)
            at android.os.Looper.loop(Looper.java:194)
            at android.app.ActivityThread.main(ActivityThread.java:5469)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:857)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
            at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:360)
            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
            at hopon.com.hopon.activity.FeedItemActivity.onCreate(FeedItemActivity.java:78)
            at android.app.Activity.performCreate(Activity.java:5226)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1151)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2448)
            at android.app.ActivityThread.access$600(ActivityThread.java:173)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1392)
            at android.os.Handler.dispatchMessage(Handler.java:107)
            at android.os.Looper.loop(Looper.java:194)
            at android.app.ActivityThread.main(ActivityThread.java:5469)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:857)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
            at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:3)

使用此主题可以解决您的问题

<style name="FeedTheme" parent="Theme.AppCompat.Light.NoActionBar">

</style>