无法使用带有 Android 兼容包的 Fragment
在“面向所有人的片段”中,Xavier Ducrohet,Android SDK 技术负责人表示,谷歌通过 SDK Manager 发布了 Android 兼容包。
我已经安装了它,但是现在我该如何使用它呢?
如何在我的项目中集成Android兼容包?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果您使用的是 Eclipse Android 支持库版本 12 或更高版本,只需右键单击您的项目,然后选择 Android Tools >添加兼容性库...
If you're using version 12 or later of the Eclipse Android support library, just right-click on your project, and choose Android Tools > Add Compatibility Library...
{yoursdkpath}/extras/android/compatibility/v4/
目录中有一个名为android-support-v4.jar
的 .jar 文件。将其复制到项目根目录中的 libs 文件夹中,并将该文件添加到 Eclipse 中的构建路径中。There is a .jar file called
android-support-v4.jar
in the directory{yoursdkpath}/extras/android/compatibility/v4/
. Copy this into your libs folder in the root of your project and add the file to the build path in Eclipse.总理,
我按照 Android 开发者博客< 上的 Fragments 示例进行操作/a> 使用片段创建“向后”兼容的应用程序。文章中简要提到了使用带有片段的布局的 Main 活动。
这里应该提到的是,该活动必须派生自 FragmentActivity 而不是 Activity 类。这让我有一段时间感到困惑。
祝你好运
Premier,
I followed the Fragments example on the Android Developers Blog to create a "backwards" compatible app using Fragments. In the article there is a brief mention of the Main activity that uses a layout with fragments.
What should be mentioned here is that this activity must derive from FragmentActivity and not Activity class. This threw me off for a while.
Good luck
参考使用Android兼容包的片段可能会有所帮助你
Refer Using Fragment of Android Compatibility Package may help you
检查“步骤 2:配置构建路径”部分此处< /a>
Check the "Step 2: Configuring the Build Path" Section here
使用我下载的新 Eclipse,这很容易。如果您正确设置了 SDK 等的所有路径,请右键单击“项目”->“ Android工具->然后点击“添加兼容性库”,它将添加 JAR 文件
This is easy with new Eclipse I downloaded. Provided you have all the paths for SDK etc setup correctly, Right click on Project -> Android tools-> and Hit "Add compatibility Library" it will add the JAR file