在定位最低API 14(ICS)时,最好使用FragmentActivity(或ActionBarActivity)或System Activity? [英] Better to use FragmentActivity (or ActionBarActivity) or system Activity when targeting min API 14 (ICS)?

查看:81
本文介绍了在定位最低API 14(ICS)时,最好使用FragmentActivity(或ActionBarActivity)或System Activity?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使我的应用具有最低Android版本4.0(ICS,API级别14).

I'm making my app to have minimum Android version of 4.0 (ICS, API level 14).

首先,我想我可以摆脱使用 FragmentActivity 作为活动的基类的问题,但是似乎某些支持库类(如 FragmentStatePagerAdapter )不可用系统框架,它需要支持 Fragment 而不是系统 Fragment .

First I guessed that I can get rid of using FragmentActivity as the base class for the activities, but it seems that some support library classes like FragmentStatePagerAdapter is not available on the system framework, and it needs the support Fragment instead of the system Fragment.

所以我想知道是否应该让我的活动从系统 Activity 继承,还是在使用appcompat库时继续使用 FragmentActivity (或 ActionBarActivity ))?

So I wonder if I should make my activities inherit from the system Activity, or stay using FragmentActivity (or ActionBarActivity when using appcompat library)?

推荐答案

某些支持库类(例如FragmentStatePagerAdapter)在系统框架上不可用,它需要支持Fragment而不是系统Fragment.

some support library classes like FragmentStatePagerAdapter is not available on the system framework, and it needs the support Fragment instead of the system Fragment.

那是不正确的. FragmentPagerAdapter FragmentStatePagerAdapter 有两种版本.一组( v4 )使用反向端口,另一组( v13 )使用本机API Level 11版本的片段.

That is incorrect. There are two versions of FragmentPagerAdapter and FragmentStatePagerAdapter. One set (v4) uses the backport, the other (v13) uses the native API Level 11 version of fragments.

我想知道我是否应该使我的活动从系统Activity中继承

I wonder if I should make my activities inherit from the system Activity

是的,除非您需要嵌套的片段.直到API Level 17才显示出来.如果您需要此功能,则需要使用backport,直到 android:minSdkVersion 为17或更高版本.

Yes, unless you need nested fragments. Those did not show up until API Level 17. If you need that capability, you will need to use the backport, until such time as your android:minSdkVersion is 17 or higher.

这篇关于在定位最低API 14(ICS)时,最好使用FragmentActivity(或ActionBarActivity)或System Activity?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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