Android:导入DrawerLayout无法解决

2022-01-10 00:00:00 layout navigation android java drawer

我正在尝试从 Android 导入使用新的导航抽屉"所需的类http://developer.android.com/design/patterns/navigation-drawer.html#ImpactOnNav

I'm trying to import the classes required to use the new "Navigation Drawer" from Android http://developer.android.com/design/patterns/navigation-drawer.html#ImpactOnNav

抽屉布局:http://developer.android.com/reference/android/support/v4/widget/DrawerLayout.html

ActionBarDrawerToggle:http://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.html

ActionBarDrawerToggle: http://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.html

无法解析导入android.support.v4.widget.DrawerLayout无法解析导入android.support.v4.app.ActionBarDrawerToggle

The import android.support.v4.widget.DrawerLayout cannot be resolved The import android.support.v4.app.ActionBarDrawerToggle cannot be resolved

我已将库更新到最新版本,但仍然无法识别这些类.

I have updated the libraries to the latest version but still these classes are not recognized.

推荐答案

如何更新库中的 JAR?

How do I update the JARs in libs?

我通常通过复制文件来做到这一点.您将在 $ANDROID_SDK/extras/android/support 中找到 JAR,其中 $ANDROID_SDK 是安装 Android SDK 的位置.

I usually do it by copying the file. You will find the JARs inside $ANDROID_SDK/extras/android/support, where $ANDROID_SDK is wherever your Android SDK is installed.

如果您使用 Eclipse,如果您在文件系统级别复制此文件,并且 Eclipse 已打开,请按 <F5> 并在包管理器中突出显示项目,以便 Eclipse 获取更改.更简单的方法是将它拖出 SDK 并将 JAR 放入 Eclipse 中的 libs/ 中,这将更新文件系统并让 Eclipse 知道更改.

If you use Eclipse, if you copy this at the filesystem level, and Eclipse is open, press <F5> with the project highlighted in Package Manager so Eclipse picks up the changes. Easier is to drag it out of the SDK and drop the JAR into libs/ right in Eclipse, which will both update the filesystem and let Eclipse know about the change.

添加 JAR 的 Eclipse 选项(右键单击项目,然后从上下文菜单中选择 Android Tools > Add Support Library...)也可能会执行此操作.由于我的开发环境的一些特殊性,这种特殊方法对我不起作用.

It's possible that the Eclipse option to add the JARs (right-click over the project, then choose Android Tools > Add Support Library... from the context menu) will also do this. That particular approach doesn't work for me due to some peculiarities with my development environment.

相关文章