android - 无法使用 Android Studio 从 Android 支持库导入 ActionBarCompat

标签 android android-studio android-actionbar-compat

我正在使用 Android Studio 并已关注 this article from google以及some other articles讨论如何使用新的 ActionBarCompat。

我已经在 Android SDK 管理器中下载了支持库(修订版 18)并在我的 build.gradle 中添加了以下内容

dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.android.support:appcompat-v7:18.0.0'
}

现在我正在尝试导入支持库 API 并在我的代码中扩展 ActionBarActivity, 然而,这就是出现的结果

enter image description here enter image description here

这不是它应该是的样子

import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;

有什么帮助吗?

最佳答案

我也遇到了同样的问题。我按照这个步骤解决了它,在 Android Studio - Tools -> Android -> Sync Project with Gradle Files

enter image description here

编辑: 对不起,我忘了添加这个: 将项目与 Gradle 文件同步后,请按照以下步骤操作:

  • 右键单击您的项目并选择打开模块设置

enter image description here

  • 之后,选择依赖选项卡

enter image description here

  • 最后 - 选择您的图书馆:

enter image description here

这应该有效。

关于android - 无法使用 Android Studio 从 Android 支持库导入 ActionBarCompat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19417666/

相关文章:

android - 确定是否可以启动应用程序中的特定 Activity

android-studio - 在Android Studio中重建项目时出错

Bintray 上的 Android 库缺少源和 javadoc

android - 新的 Theme.AppCompat ActionBar 高度

android - 如何将上下文操作栏 (CAB) 与 support.v7.widget.Toolbar 和 Listview 一起使用?

android - 如何像手机应用程序一样发出通知

安卓 SQLite : Which query ("query" or "rawQuery") is faster?

android - 如何检查给定的应用程序是安装在内部还是外部存储上

由于输出 jar 库为空,Android Studio proguardRelease FAILED

android - 在对其应用自定义 View 之前,actionbar 会显示一段时间