V4支持库是否可用时使用新的类? [英] Does v4 support library use new classes when available?

查看:184
本文介绍了V4支持库是否可用时使用新的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据了解,现在的 V4支持库的可用于已经在最近的版本被引入旧的Andr​​oid版本的东西,比如片段来实现。如果我们实现一个应用程序,使用 V4支持库的显示的对话片段的,例如,它采用最新的code(即原来的和新的片段),当它运行在ICS或做它仍使用支持code的每一个Android版本?

I know that the v4 support library can be used to implement in old android versions things that have been introduced in more recent versions, such as Fragments.. If we implement an app that uses the v4 support library to display Dialog Fragments, for example, does it use the latest code (i.e. the original and newer fragments) when it runs on ICS or does it still use the support code for every android version?

有没有办法在同一应用程序同时使用 android.app.Fragment 类和 android.support.v4.app。片段类,区别在运行时,如果我们在片段功能的版本运行的Andr​​oid的还是我们需要只有当我们导入使用支持类的 V4支持库的?

Is there a way to use in the same app both the android.app.Fragment class and the android.support.v4.app.Fragment class, distinguishing at runtime if we are running on a Fragment-enabled release of android or do we need to use only the support classes when we import the v4 support library?

也许我错了,但它似乎并没有给我一个好主意,而不是最近的平台上运行时要使用最新的code ..

Maybe I'm wrong, but it does not seem to me a good idea not to use the latest code when running on recent platforms..

留恋的对话片段的情况下,你觉得这是更好的:

Sticking to the Dialog Fragment case, what do you think it is better:

1)使用的 V4支持库的,在所有的Andr​​oid版本的IE使用的兼容性code

1) use the v4 support library, i.e. use compatibility code on all android versions

2)使用新的 android.app.DialogFragment 在API级别运行11或以上,使用德$ P $时pcated 的ShowDialog onCreateDialog 在API上运行时的活动类的方法水平< 11

2) use the new android.app.DialogFragment when running on API level 11 or above and use the deprecated showDialog and onCreateDialog methods of the Activity class when running on API level < 11

正如我已经说过,最好的一个恕我直言会是以下,但(纠正我,如果我错了)它不是一个可行的解决方案:

As I've already said, the best one IMHO would be the following, but (correct me if I'm wrong) it is not a possible solution:

3)在API级别运行11或以上时,使用新的 android.app.DialogFragment 类,并使用 android.support.v4.app.DialogFragment 类; 11

3) use the new android.app.DialogFragment class when running on API level 11 or above and use the android.support.v4.app.DialogFragment class when running on API level < 11

我很抱歉,如果我做了一个有点混乱,我希望这个问题是很清楚的。

I'm sorry if I made a bit of confusion, I hope the question is quite clear..

推荐答案

当您使用支持Android libary在你的项目,即使该设备具有的Andr​​oid兼容的API级别,这样它不需要使用兼容性库,它仍然会使用来自compatibillity库的方法。

When you use the android support libary in your project, even if the device has a compatible API level of Android so that it does not need to use the compatibility library, it will still use the methods from compatibillity library.

修改

浏览Android的支持库V4 code它规定(注释中的 android.support.v4.app.Fragment 类):

Browsing the Android support library v4 code it states (in comments in android.support.v4.app.Fragment class):

该框架的静态库的支持版   android.app.Fragment。用来写前的平台上运行的应用程序   到Android 3.0。在Android 3.0上运行或以上,这在   实施仍在使用;它并不试图切换到   框架的实现。见框架SDK文档一   类概述。

Static library support version of the framework's android.app.Fragment. Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework SDK documentation for a class overview.

链接<一个href="http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/4.0.1_r1/android/support/v4/app/Fragment.java#Fragment"相对=nofollow>这里。

这篇关于V4支持库是否可用时使用新的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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