zoukankan      html  css  js  c++  java
  • 关于新版SDK报错You need to use a Theme.AppCompat theme的两种解决办法

    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>

    即可

  • 相关阅读:
    jQuery——能够编辑的表格
    最简单的Windows程序
    数据库分页查询
    Srvctl命令具体解释(10g)
    AT3912 Antennas on Tree
    使用GenericServlet实例
    Servlet接口、GenericServlet类、HttpServlet类
    Servlet简介
    MVC
    为JSP写的一套核心标签
  • 原文地址:https://www.cnblogs.com/zhujiabin/p/5686366.html
Copyright © 2011-2022 走看看