简体   繁体   English

在android中的Style.xml上出错

[英]Getting error on Style.xml in android

My problem is that i am getting error on styles.xml in my android project.May be due to that my R.java is not generating.I am using Support library appcompact_V7 support library.我的问题是,我在收到错误styles.xml在我的Android project.May是由于我的R.java没有generating.I正在使用支持库appcompact_V7支持库。 Can anyone specify what error I made in my program.任何人都可以指定我在我的程序中犯了什么错误。 Here is my code....这是我的代码....

Styles.xml样式文件

 <resources>

        <!--
            Base application theme, dependent on API level. This theme is replaced
            by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
        -->


{ AT THE BELOW LINE I AM GETTING THE ERROR}

        <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
            <!--
                Theme customizations available in newer API levels can go in
                res/values-vXX/styles.xml, while customizations related to
                backward-compatibility can go here.
            -->
        </style>

        <!-- Application theme. -->
        <style name="AppTheme" parent="AppBaseTheme">
            <!-- All customizations that are NOT specific to a particular API-level can go here. -->
        </style>

    </resources>

My android manifest.xml我的 android manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.bq.sample"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"

        android:theme="@android:style/Theme.AppCompat.Light" >

        <activity
            android:name=".Image"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

You just have to change the style to你只需要改变风格
<style name="AppBaseTheme" parent="android:Theme.Light">
instead of代替
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
And if you are still facing error like No resource identifier found for attribute 'showAsAction' in package , then just remove android:showAsAction="never" from res/menu folder from every xml file.如果您仍然面临类似No resource identifier found for attribute 'showAsAction' in package ,那么只需从每个 xml 文件的 res/menu 文件夹中删除android:showAsAction="never"

在我们的style.xml更改第一个样式标签如下:

<style name="AppBaseTheme" parent="android:Theme.Light">

I got the error that cannot resolve symbol 'Theme.AppCompat.Light'我收到无法解析符号“Theme.AppCompat.Light”的错误

I'm not sure is it same problem with you.我不确定你是否有同样的问题。 This method solved my problem.这个方法解决了我的问题。

  1. Go to your project directory (or to Project View)转到您的项目目录(或项目视图)
  2. Find and open .idea directory查找并打开 .idea 目录
  3. Remove caches and libraries directories <-- this is essential删除缓存和库目录 <-- 这是必不可少的
  4. Invalidate Caches / Restart使缓存无效/重新启动

Ref: https://github.com/red5pro/streaming-android/issues/31参考: https : //github.com/red5pro/streaming-android/issues/31

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM