在 Android API 7 上实现操作栏
我正在使用 API v7 开发 Android 2.1。
如何在旧版本 API 中实现操作栏,使其在支持 API 11 或更高版本的设备上像内置 ActionBar 一样工作?有支持包吗?
(关于如何在旧版本 API 中实现操作栏的好教程值得赞赏)
I am working on Android 2.1 with API v7.
How can I implement the action bar in this old version API which can work like built-in ActionBar on devices supporting API 11 or greater? Is there any support package ?
(A good tutorial on how to implement action bar in old version API is appreciated)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是将带有幻灯片菜单的 actionBar 添加到 api>7 的示例:
https://github.com/BradleyRL/ NavDrawerExampleAppCompat-v7
此处记录了 api>14 http://developer.android.com/training/implementing-navigation/nav-drawer .html。 (第一个链接 - 是第二个链接的升级方法以支持以前的版本)。
然后,您可以在此处阅读文档:developer.android.com/guide/topics/ui/actionbar.html
为此,您必须将项目库添加到您的项目中(例如也在 1t 链接中)。
为此:文件>新建>其他>来自现有代码的Android项目>浏览(选择“YOUR_PATH_TO_ANDROID_SDK\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20131030\sdk\extras\android\support\v7\appcompat”),检查将其添加到工作区>完成。
然后转到您的属性(第一个链接中的示例)项目> android>添加(选择此库)>确定。
并且您必须从 ActionBarActivity 而不是 Activity 扩展您的主类。我尝试了这个,它适用于 2.3.7 和 4.1.1 版本)
希望它有帮助)
PS 抱歉我的英语不好,来自俄罗斯的嗨)
Here is an examle of adding actionBar with slides menu to api>7:
https://github.com/BradleyRL/NavDrawerExampleAppCompat-v7
It's documented here for api>14 http://developer.android.com/training/implementing-navigation/nav-drawer.html. (first link - is upgraded method of second link to support previous versions).
Then, you could read documentation here: developer.android.com/guide/topics/ui/actionbar.html
To do this this way you must add project library to your project (and for exammple in 1t link too).
To do it: File>New>Other>Android Project From Existing Code>Browse (Select "YOUR_PATH_TO_ANDROID_SDK\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20131030\sdk\extras\android\support\v7\appcompat"), check adding it to workspace>Finish.
Then go to properties of your(example in 1st link) project>android>add (choose this library)>OK.
And you must extend your main class from ActionBarActivity insted of Activity. I try this, and it work on 2.3.7 and on 4.1.1 versions)
Hope it helps)
P.S. Sorry for my bad english and hi from Russia)
您可以/应该使用此 ActionBar 项目。
它使用起来非常非常简单,我自己也在一个项目中使用它。
You can/should use this ActionBar project.
It's very very simple to use and I am using it myself in one project.