android的一个小问题:

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


法一:

当在AndroidManifest.xml文件的application的节点设置了属性:

android:theme="@android:style/Theme.NoTitleBar

而Activity继承了ActionBarActivity就回出现上述错误,解决的办法就是让Activity去继承Activity而不是ActionBarActivity

改完之后删掉报错的部分,然后别忘了导入Activity包

法二:

在AndroidMenifest.xml中加入一句:

android:theme="@style/Theme.AppCompat.Light.NoActionBar"
例子:

 <activity android:name="com.vmoksha.BaseActivity" android:label="@string/app_name" android:theme="@style/Theme.AppCompat.Light.NoActionBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
然后在styles.xml中加入主题资源:

 <style name="Theme.AppCompat.Light.NoActionBar" parent="@style/Theme.AppCompat.Light"> <item name="android:windowNoTitle">true</item> </style>
即可

更多相关文章

  1. Android全部源码导入Eclipse
  2. Android(安卓)[error cannot connect to daemon]
  3. 关于cocos2dx的eclipse的"serializing cdt project settings"解
  4. ListView中添加Button后,Button的点击事件和ListView的点击事件冲
  5. [android] No resource found that matches the given name 'The
  6. Android官方技术文档翻译—— Eclilpse项目迁移
  7. Android(安卓)studio导入eclipse项目
  8. Android基础知识:Day02 常见布局、logcat相关和文件读写
  9. 使用 Eclipse PhoneGap 构建 Android(安卓)应用程序入门

随机推荐

  1. Android(安卓)模拟器
  2. Android(安卓)Activity启动模式介绍
  3. android方向键被锁定的问题
  4. android触控,先了解MotionEvent(一)
  5. 《Android面试宝典》学习笔记(第七章:网络
  6. Android学习笔记(六)-文件操作与SDCard读写
  7. 使用android模拟事件,python完成自动化测
  8. 【读书笔记】【Android(安卓)开发艺术探
  9. Android自定义Gallery,实现CoverFlow效果
  10. Android中用OpenGL ES Tracer分析绘制过