我的android studio 无法预览xml文件

我的android studio 无法预览xml文件

老师, 我的android studio 无法预览xml文件; 刷新了也不行! 

Failed to load AppCompat ActionBar with unknown error.   Tip: Try to refresh the layout.


The following classes could not be instantiated:

- android.support.v7.widget.ActionBarContainer (Open Class, Show Exception, Clear Cache)

- android.support.v7.widget.ActionBarContextView (Open Class, Show Exception, Clear Cache)

- android.support.v7.app.WindowDecorActionBar (Open Class, Show Exception, Clear Cache)

 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  If this is an unexpected error you can also try to build the project, then manually refresh the layout.  Exception Details java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener Copy stack to clipboard 

http://img1.sycdn.imooc.com//climg/5b28ab910001aa6f18981046.jpg

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
irista23 2018-06-19 15:36:26

 你在当前module下找到下图红框中的文件,将name为AppTheme的parent值改为Base.Theme.AppCompat.Light.DarkActionBar或AppBaseTheme

http://img1.sycdn.imooc.com//climg/5b28b1f10001a09802690346.jpg

  • 提问者 飞翔吧吧 #1
    设置为Base 后整个页面无显示, 还请大神告知是什么原因导致的?
    2018-06-19 16:15:41
  • irista23 回复 提问者 飞翔吧吧 #2
    Base.Theme.AppCompat.Light.DarkActionBar设置没有效果可能没有找到Theme.AppCompat.Light主题,项目缺少android-support-v7-appcompat库,可以通过Android SDK Manager下载最新的Android Support Library,或者将AndroidManifest.xml文件里面,minSdkVersion改成14,将项目values,values-v11,values-v14目录下的styles.xml文件里面style都改为我上面说的第二种<style name="AppTheme" parent="AppBaseTheme"></style>
    2018-06-19 17:06:09
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师