既然 TabActivity 已弃用,则使用 Fragments 创建选项卡
我正在创建一个应用程序,该应用程序在屏幕底部有五个选项卡,每个选项卡都会打开一个不同的活动。
我的选项卡活动扩展了我刚刚读到的选项卡活动已被弃用,我应该使用片段代替。
如何更改我的应用程序以使用 Fragment?我已阅读 android.developer.com 上的信息,但我仍然不知道如何执行此操作。
I am creating an application which has five tabs at the bottom of the screen, each of which opens a different Activity.
My Tab Activity extends TabActivity which I have just read is deprecated and I should use Fragments instead.
How do I change my app to use Fragments instead? I have read the information on android.developer.com but I still have no idea how to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用 android 兼容性库才能使用片段。它可以作为 jar 文件在您的 android sdk 文件夹中找到。
有很多关于片段的教程。
有一个名为 ActionBarSherlock 的项目,它演示了兼容性库的所有功能。源代码也可以在 github 上找到。该链接位于该网站上。
这是另一个教程
http://mobile.tutsplus.com/tutorials/android/android-compatibility-working -带片段/
You will need to use the android compatibility library to use fragments. It can be found as a jar file in your android sdk folder.
There are many tutorials out there for fragments.
There is a project named ActionBarSherlock which demos all the capability of the compatibility library. Source code is also available on github. The link is on there site.
This is another tutorial
http://mobile.tutsplus.com/tutorials/android/android-compatibility-working-with-fragments/