在 Android API 7 上实现操作栏

发布于 2025-01-02 19:47:11 字数 199 浏览 2 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

留蓝 2025-01-09 19:47:11

以下是将带有幻灯片菜单的 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)

逆夏时光 2025-01-09 19:47:11

您可以/应该使用 ActionBar 项目。
它使用起来非常非常简单,我自己也在一个项目中使用它。

You can/should use this ActionBar project.
It's very very simple to use and I am using it myself in one project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文