小编bno*_*ite的帖子

无法更改ActionBar的背景颜色

我正在尝试更改Android应用的背景颜色,但我无法做到.我搜索了很多帖子,但没有解决方案解决了我的问题.

这是我的styles.xml:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/ActionBar</item>
</style>

<style name="ActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:background">#ff0000</item>
</style>


</resources>
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我只是想将条形设置为红色.这是我的清单:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MenuActivity"
        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>
Run Code Online (Sandbox Code Playgroud)

正如您所见,主题已正确设置.只是你可以看到,这是我的傻瓜:

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    ...
    minSdkVersion 15
    targetSdkVersion 21



}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}
Run Code Online (Sandbox Code Playgroud)

所以,即使这看起来不错,也没有将我的ActionBar设置为红色.我试着跟随很多指南(包括官方指南),我已按照他们的说法做了一切.我错过了什么?感谢您提前耐心:)

android android-actionbar

2
推荐指数
1
解决办法
2806
查看次数

摆脱警告:在flex中隐式声明函数'fileno'

当我尝试编译我的野牛和flex文件时,我正试图摆脱gcc抛出的警告:

: In function ‘yy_init_buffer’:
:1675: warning: implicit declaration of function ‘fileno’
Run Code Online (Sandbox Code Playgroud)

我想要这样做的原因是因为我正在尝试向我正在使用的类提交作业但我只能提交"parser.y"和"scanner.l"文件并进行远程编译.问题是:如果有警告它(由于某种原因)被认为是错误,并且因为我无法控制编译器标志,所以我无法使其消失.我在互联网上看到了同样问题的一些问题,但没有提到的解决方案对我有用.

编译器使用以下标志:

bison -d -o parser.c parser.y
flex -i -o scanner.c  scanner.l
gcc -std=c99 -pedantic -o test_parser *.c
Run Code Online (Sandbox Code Playgroud)

我正在使用Mac OSX所以当我编译它时没有给我任何警告,所以我猜它是linux发行版独有的东西.这是我拥有的每个文件的标题部分,因此您可以了解我已经尝试过的内容:

scanner.l

#define _POSIX_SOURCE 1
//#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>
# include "parser.h"
Run Code Online (Sandbox Code Playgroud)

parser.y

#include <stdio.h>
#include <stdlib.h>

int yylex (void);
void yyerror (char const *);
Run Code Online (Sandbox Code Playgroud)

真的很感激这里的任何帮助.

c warnings bison suppress-warnings flex-lexer

1
推荐指数
1
解决办法
2507
查看次数