Android You need to use a Theme.AppCompat theme (or descendant) with this activity.

错误描述为:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

起因:
我想在Manifest中设置我的activity全屏,代码如下:

        <activity
            android:name=".MainActivity"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:label="@string/app_name" >

原因:
从错误提示中提到Theme.AppCompat theme,这是因为我们的activity一定是继承了兼容包中的类,
比如我这里就无意中继承了ActionBarActivity,它来自android.support.v7.app.ActionBarActivity。
所以就要使用与其配合的AppCompat的theme才行。

解决:
1.根据提示来使用AppCompat的theme,如下:

        <activity
            android:name=".MainActivity"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"
            android:label="@string/app_name" >

http://blog.csdn.net/lincyang/article/details/42673151

2.如果不是那么强烈需要继承自ActionBarActivity,就直接继承Activity吧。问题自然搞定!

时间: 2024-08-03 19:01:17

Android You need to use a Theme.AppCompat theme (or descendant) with this activity.的相关文章

我的Android进阶之旅------&gt;解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.

#1.错误描述 今天,想实现Activity不显示标题栏的效果,在项目的AndroidManifest.xml文件,对相应的Activity添加属性 android:theme="@android:style/Theme.NoTitleBar" 具体代码如下: <activity android:name=".module.view.activity.KuwoMusicPlayActivity" android:theme="@android:sty

开发中遇到的问题(一)——java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

1.错误描述: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 2.起因: 在Manifest中设置我的activity全屏 1 <activity android:name=".SplashActivity" 2 android:theme="@android:style/Theme.Black.No

关于引用Theme.AppCompat theme的报错问题

建立V7包库(Library)项目以供其他项目引 Chapter: 使用support-v7 ActionBar前的那些坑 1. 建立V7包库(Library)项目以供其他项目引用 2. v7库项目themes_base.xml相关文件报错问题 3. 关于引用Theme.AppCompat theme的报错问题 以前3.0以前的版本要使用ActionBar,必须使用国外大牛写的ActionBarSherlock这个开源项目.2013年的Google I/O大会之后,Google官方在androi

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

错误描述:java.lang.IllegalStateException: You need to use a theme.appcompat theme (or descendant) with this activity 产生原因:Activity继承自AppCompatActivity,在style.xml中使用了不兼容的Theme. 从错误提示中提到Theme.AppCompat theme,这是因为我们的activity一定是继承了兼容包中的类,比如我这里就无意中继承了AppCompa

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme

配置: 中设置theme为 <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:theme="@android:style/Theme.Light.NoTitleBar" android:label="@string/app_name" > 报错信息: 09-20 10:31:58.185 1392-1

关闭 You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法

当我的MainActivity继承自v7包中的ActionBarActivity或者AppCompatActivity时,如果在style.xml文件中指定MainActivity所使用的样式如下: [java] view plain copy <style name="AppTheme" parent="android:Theme.Material.NoActionBar"> <!-- 5.0开始,可以在Style.xml文件中统一配置App的样

You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法

报错如下:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.test2/com.example.test2.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 解决方法:创建的activity是M

you need to use a theme.appcompat theme (or descendant) with this activity 解决办法

当你想隐藏 Androidmanifest.xml <activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.acti

Android studio使用android:style/Theme.Dialog报错:You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)

查找原因是在activity java代码部分继承了compatactivity public class DialogActivity extends AppCompatActivity 但是在AndroidManifest.xml里面确定义成Dialog, <activity android:name=".DialogActivity" android:theme="@android:style/Theme.Dialog"></activity