Android Studio中报错 You need to use a Theme.AppCompat theme (or descendant) with this activity
2016-04-07 00:10
423 查看
1.错误描述:
FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.best.keke.tabdemo01/com.best.xxxx.tabdemo01.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.2.原因:在AndroidManifest.xml文件中使用了
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
在MainActivity 中我继承了 AppCompatActivity。这是因为AppCompatActivity是v7兼容包里面的。所以此处需要用到兼容包中的theme即可。
3.解决如下:
a.
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/Theme.AppCompat.Light.NoActionBar">
b.或者在MainActivity 中继承了Activity即可。
参考链接:1.http://stackoverflow.com/questions/26689279/java-lang-illegalstateexception-you-need-to-use-a-theme-appcompat-theme-or-des2.http://stackoverflow.com/questions/18063395/actionbarcompat-java-lang-illegalstateexception-you-need-to-use-a-theme-appcom
相关文章推荐
- 布局概述之相对布局RelativeLayout
- Check复选框的监听实现
- 多选一机制的实现(RadioButton的实现)
- 实现自动匹配的输入文本
- ToggleButton 的功能 实现(同过实现OncheckChangeListener接口)
- 按钮的监听事件--onClick
- Android 控件及其属性2
- Android 控件和其基本属性1
- 人脸识别测颜值、测脸龄、测相似度微信接口
- MVC和MVP在app中的对比分析以及实际应用
- application 的用法
- [IOS]NSObject--用于传值
- Multiple dex files define Landroid/support/annotat
- function call 和 apply bind
- eventbus/documentation/delivery-threads-threadmode
- eventbus/documentation/how-to-get-started/
- iOS APP瘦身
- 001.【笔记】android socket 初步认识
- An App ID with Identifier 'XXX’ is not available
- 设置透明导航栏