片段中的Andr​​oid 2.2.1,2.3,2.0。这可能吗? [英] Fragments in Android 2.2.1, 2.3, 2.0. Is this possible?

查看:124
本文介绍了片段中的Andr​​oid 2.2.1,2.3,2.0。这可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我想知道,如果我们能有片段布局在了Android OS&LT装置; 3.0。

Basically I would like to know if we can have fragment layouts in devices with Android OS < 3.0.

我的应用程序对顶部的头5个不同的按钮和开始总是第一个按钮被点击默认情况下,所以下面这些按钮的看法是第一个观点。现在,当你点击它旁边的第二个按钮,我不希望被刷新,而只是它下面的视图需要刷新头的图像。因此,它像更新片段下方的标题图片的按钮。

My app had a header on top with 5 different buttons and on start always the first button is clicked by default so the view below these buttons is for the first view. Now when you click on the second button beside it, I don't want the header images to be refreshed but the view just below it needs to be refreshed. So its like updating the fragments below the header image buttons.

所以我们可以有碎片的Andr​​oid与OS&LT装置; 3.0。

So can we have fragments in Android in devices with OS < 3.0.

萨那。

推荐答案

您必须使用由谷歌提供的兼容性库。这里是你如何使用碎片上的设备&LT; 3.0

You have to use the compatibility libraries provided by Google. Here's how you use Fragments on devices < 3.0

  • 打开Eclipse
  • 窗口 - > Android SDK和AVD
  • 可包 - > Android的支持包(安装此)

安装后,右键单击要添加片段支持的Andr​​oid项目。

Once installed, right click the Android project you want to add Fragment support for.

  • 在构建Path->配置构建路径
  • 在库标签
  • 添加外部JAR
  • 加入了Android的支持 - v4.jar(应该是群众演员下了android下载文件夹/安卓/支持/ V4

现在你的应用程序支持片段。有一些关键的不同使用兼容包在使用SDK 3.0+。例如

Now you application supports Fragments. There are some key differences to using the compatibility package over using SDK 3.0+. For instance

  1. 在使用碎片的活动课必须扩展 FragmentActivity 不是活动
  2. 而不是 getFragmentManager()你必须使用 getSupportFragmentManager
  1. The activity classes that use fragments must extend FragmentActivity NOT Activity.
  2. instead of getFragmentManager() you have to use getSupportFragmentManager

享受!

这篇关于片段中的Andr​​oid 2.2.1,2.3,2.0。这可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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