错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
来源:互联网 发布:与sqlserver建立连接 编辑:程序博客网 时间:2024/04/30 07:50
错误提示:07-01 00:42:39.109: E/AndroidRuntime(17157): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android_007_dialogtest/com.example.android_007_dialogtest.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
问题出现的原因:
想要设置APP的显示规则,即设置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.将MainActivity.java中的主类继承方式修改,即将继承自ActionBarActivity类,修改直接继承Activity。则问题可解,如下图所示,修改此处内容为Activity
解决方法2.根据提示来配合使用AppCompat中的theme,如下:
- <activity
- android:name=".MainActivity"
- android:theme="@style/Theme.AppCompat.Light.NoActionBar"
- android:label="@string/app_name" >
以上就是解决You need to use a Theme.AppCompat theme (or descendant) with this activity.的两种方法
- 关于“you need to use a theme.appcompat theme (or descendant) with this activity”错误
- You need to use a Theme.AppCompat theme (or descendant) with this activity错误解决
- Android错误之:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- 错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- 错误:You need to use a Theme.AppCompat theme (or descendant) with this activity
- Android 解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity
- Android错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- 解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android开发~you need to use a theme.appcompat theme (or descendant) with this activity
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- 【Android】You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- You need to use a Theme.AppCompat theme (or descendant) with this activity解决
- you need to use a theme.appcompat theme (or descendant) with this activity 解决办法
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- UE4创建透明水的效果
- 编译go1.7beta2
- [强烈推荐] thinkphp iis7.5 win2008 上 设置虚拟静态 错误的解决方法 web.config
- [九度OJ]最短路径
- Codeforces 543 A Writing Code 计数DP
- 错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- 怎样拼读单词
- GetModuleFileNameEx遍历获取64bit程序路径失败的一种解决方法(Win7-64-bit)
- UE4发布android应用
- spring boot 学习笔记(008)mysql
- UITabBarController的使用
- jdk的安装
- Swift 容器类型总结
- Solr实时查询模型