- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在使用昨天发布的 ActionBarCompat 支持库时遇到问题。我已经更新了支持存储库,并在 build.gradle 中包含了 appcompat-v7 存储库的路径,正如 Chris Banes 在 DevBytes 中指出的那样 - https://www.youtube.com/watch?v=6TGgYqfJnyc .
dependencies {
compile ('com.android.support:support-v4:18.0.+')
compile ('com.android.support:appcompat-v7:18.0.+')}
构建进展顺利,我可以使用该库中的类,例如 ActionBarActivity,但我不能使用样式和任何资源,所以我不能使用以下主题 - @style/Theme.AppCompat 等。我想我会找到源文件在 .../sdk/extras/android/.../"supportrepo"中,所以我会像 gradle 的 ActionBarSherlock 一样引用它,但这似乎不是正确的答案。
我做错了什么?谢谢。
最佳答案
我使用的是 Android Studio,我在 values/styles.xml
中遇到了同样的分辨率问题。
它说它无法解析@style/Theme.AppCompat.Light
,但在编译时(gradle)和运行时一切正常(Android 2.3 .3 和 4.3)。
我想去掉无法解析 res 的警告。
我如何告诉 Android Studio 这个资源可以在 appcompat-v7 存储库中找到?
(此问题与 Android Studio 中已修复的错误有关。)
下面你会看到我做了什么。我希望这将有所帮助。赞赏建议。
appcompat 库的源代码可以在 github 上找到.
dependencies {
...
compile group:'com.android.support', name:'appcompat-v7', version:'18.0.+'
...
}
值/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.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.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="@style/Theme.AppCompat.Light">
<item name="actionBarStyle">@style/ActionBar.Solid.Custom</item>
</style>
<style name="ActionBar.Solid.Custom" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">@drawable/ab_solid_custom</item>
<item name="displayOptions">homeAsUp|showHome|showCustom</item>
</style>
</resources>
values-v14/styles.xml:
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 14 theme customizations can go here. -->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/ActionBar.Solid.Custom</item>
</style>
<style name="ActionBar.Solid.Custom" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">@drawable/ab_solid_custom</item>
<item name="android:displayOptions">homeAsUp|showHome|showCustom</item>
</style>
</resources>
MainActivity (只有扩展是必需的):
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Views.inject(this);
setupNavigationDrawer();
}
}
AndroidManifest.xml (必须设置 android:theme):
<activity
android:name="com.example.app.MainActivity"
android:theme="@style/AppTheme"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
关于Android ActionBarCompat 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17856531/
我对 ActionBar 微调器有疑问。我正在使用 ActionBarCompat。我在 Gingerbread、JB 和 KK 上看到了这个问题。 这是我的 Activity : public cl
我已经创建了以下 xml 文件来将样式应用到我的 ActionBar,但它不起作用 @style/MyActionBar @color/actionbar_color
我使用的是 Android 4.2 和 minSdkVersion 17,该应用程序适用于平板电脑。 我可以修改默认主题(只更改我的操作栏的颜色)但找不到。 我的 list 是:
好的,我一直想尝试新的 ActionBarCompat,但是,我无法在模拟器中运行我的程序。 我一直在尝试实现以下内容:http://antonioleiva.com/actionbarcompat-
我想我在这里遗漏了一些东西。 在引用文档中找到这个示例后,我想对其进行测试。因此,我通过导入这个项目创建了一个新项目 - 目标是 SDK 的 v2.3。 但是,打开项目时,出现51错误。 我的问题是,
我正在使用 actionbarcompat 库,但我遇到了一个奇怪的问题。操作栏标题被异常截断。不知道是什么原因。 最佳答案 我试图弄清楚可能是什么原因。这就是我的想法。 我在使用 ViewPager
我正在开发一个使用扩展 @style/Theme.AppCompat.Light.DarkActionBar 主题的应用程序. 在我的一个 Activity 中,有一个操作栏图标显示三个带有单选按钮的
这个问题在这里已经有了答案: Actionbar not shown with AppCompat (3 个答案) 关闭 8 年前。 这是我的general.xml 文件
我正在尝试在我自己的项目中使用 ActionBarCompat。我已经打开示例项目(http://developer.android.com/resources/samples/ActionBarCo
我已经开始使用 AppCompat 库附带的 ActionBar。但是我添加的任何操作都会显示在溢出菜单中。我很确定我已经跳过了一些东西,但我根本不知道。这是我的菜单文件: o
我在使用昨天发布的 ActionBarCompat 支持库时遇到问题。我已经更新了支持存储库,并在 build.gradle 中包含了 appcompat-v7 存储库的路径,正如 Chris Ban
我在我的应用程序中使用 ActionBarCompat,我想在操作栏中显示一两个项目 我遵循了谷歌开发人员的指南,但是当我测试它时,这些项目显示在“溢出”选项中(在 Nexus 4 中),如果我点击菜
我实现了 ActionBarCompat 以在不同的操作系统版本中拥有一个 ActionBar。 它隐藏在智能手机上,仅在平板电脑上显示。 我在这张截图中看到:http://developer.and
这几天我一直在为一个问题而苦恼。非常感谢您的帮助! 当我使用目标 API 级别 14 构建/运行示例“ActionBarCompat”时。一切正常。 然后我切换到目标 API 级别 8(毕竟,这是为了
是否可以将 FadingActionBar ( https://github.com/ManuelPeinado/FadingActionBar-Native ) 库与 Google 的新 Actio
ActionBar actionBar = getSupportActionBar(); mDrawerList.setAdapter(new ArrayAdapter(this,R.layout.d
我正在使用最新版本的支持库 (V21),其中包括 Material 主题(在 Theme.AppCompat 名称下),我想将 ActionBar 标题设置为白色。我试图通过在我的自定义主题中使用 t
我遇到了错误“未为 MainActivity 类型定义方法 getSupportActionBar()” import android.app.FragmentTransaction; import
我正在尝试将 ActionBarCompat 集成到我的一个项目中。我使用 Gradle 构建系统。 我已将依赖添加为: dependencies { compile 'com.android
我正在为我的 android 项目使用 actionbarcompat 并使用 @style/Theme.AppCompat.Light.DarkActionBar 作为我的基本主题。默认情况下,此操
我是一名优秀的程序员,十分优秀!