support.v7.widgets和android.widgets工具栏,片段之间的区别 [英] Difference between support.v7.widgets and android.widgets Toolbar, Fragment

查看:56
本文介绍了support.v7.widgets和android.widgets工具栏,片段之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个新的应用程序,将不得不处理ActionBar.我知道我必须扩展AppCompatActivity,因为不赞成使用ActionBarActivity,但是即使我使用的是最新的API,我仍然不明白为什么我必须使用support.v7.widget工具栏而不是android.widget工具栏?/p>

谢谢

我现在了解到,使用support.v7.widgets可以使具有旧API的设备了解较新版本中添加的新功能,并以自己的方式模仿它们.那是正确的吗?

如果这是正确的,并且我不希望有任何向后兼容性,这是否意味着我可以前进并使用android.widget工具栏?

不幸的是,我也无法使用android.widget Fragment将其添加到ViewPager中.这是为什么 ?为什么它会迫使我使用已扩展的旧版本,以模仿该组件的新实现的行为?

我想我只是迷失在所有这些支持"库中.有人可以简短地(或不可以)解释所有这些吗-为什么支持库中的某些内容未包含在API的较新版本中或未进行更新?

谢谢

解决方案

首先,您要问一个好问题,Android将在不同的API级别上连续添加高级功能,但是这些功能可以从添加的API级别中获得

例如:考虑到在API级别11中添加了android片段功能,这意味着它可以在API级别11和更高版本下使用,但是那时您的应用程序也需要API级别10的设备工作.因此,android开发支持库可覆盖各种Android设备(支持低级API)以使用这些功能.

Android始终建议开发人员使用支持库进行开发以获取更多信息,请在此处

I am creating a new application and will have to deal with ActionBar. I know that I have to extend the AppCompatActivity because the ActionBarActivity is deprecated, however I still do not understand why I have to use the support.v7.widget Toolbar rather than the android.widget Toolbar even though I am using the latest API ?

Thank you

EDIT1:

I understand now that the support.v7.widgets are there to enable devices with old APIs to comprehend what are the new functionalities added in the newer versions and mimic them in their own way. Is that correct ?

If that is correct and I do not want to have any sort of backwards compatibility does this mean I can move forward and use the android.widget Toolbar ?

Also using the android.widget Fragment unfortunately I can not add it to a ViewPager. Why is that ? Why does it force me to use an older version which has been extended to mimic the behaviour of the new implementation of the component ?

I think I just getting lost in all of those "support" libraries. Can someone briefly ( or not ) explain all that - why are there things in the support libraries that are not included or updated in the newer versions of the API ?

Thank you

解决方案

First of all you are asking Good Question, Android will add advanced features continuously in different API levels but those features are available from which level of API they are added

For Example: Consider android fragment functionality was added in API level 11 that means it will work for API level 11 and above but your application need for API level 10 devices also at that time it wont be work. For this reason android develop support library for cover a wide range of Android devices (support for low level API) to work those functionality.

Android always recommend developers to use support library for development for more information check here

这篇关于support.v7.widgets和android.widgets工具栏,片段之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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