由于 TabActivity 已被弃用,因此使用 Fragments 创建选项卡 [英] Creating tabs using Fragments now that TabActivity is deprecated

查看:42
本文介绍了由于 TabActivity 已被弃用,因此使用 Fragments 创建选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,它在屏幕底部有五个选项卡,每个选项卡打开一个不同的活动.

I am creating an application which has five tabs at the bottom of the screen, each of which opens a different Activity.

我的 Tab Activity 扩展了我刚刚阅读的 TabActivity 已被弃用,我应该改用 Fragments.

My Tab Activity extends TabActivity which I have just read is deprecated and I should use Fragments instead.

如何更改我的应用以使用 Fragment?我已阅读 android.developer.com 上的信息,但我仍然不知道如何执行此操作.

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.

推荐答案

您将需要使用 android 兼容性库来使用片段.它可以作为 jar 文件在您的 android sdk 文件夹中找到.

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.

有一个名为 ActionBarSherlock 的项目,它演示了兼容性库的所有功能.源代码也可以在 github 上找到.链接在那里的网站上.

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.

这是另一个教程http://mobile.tutsplus.com/tutorials/android/android-compatibility-working-with-fragments/

这篇关于由于 TabActivity 已被弃用,因此使用 Fragments 创建选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆