[英]Add library in android Studio
Its very hard to describe my problem but I'll do my best << 很难描述我的问题,但我会尽力而为。<<
when I want to make a ViewPager in MainActivity , I go to xml then : 当我想在MainActivity中创建ViewPager时,我转到xml:
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/viewPager"
/>
then I make an Adapter 然后我做一个适配器
public class MyAdapter extends FragmentPagerAdapter
here , I need to import 在这里,我需要导入
android.support.v13.app.FragmentPagerAdapter;
the QUESTION is ; 问题是 ;
is there any problem when I use v4 , v13 on one application 在一个应用程序上使用v4,v13时有什么问题吗
note : I add the v13 library and make it as (provided) 注意:我添加了v13库并将其设置为(提供)
Edit: There shouldn't be a problem using both, just don't set it as provided. 编辑:两者都应该没有问题,只是不要按提供的那样进行设置。 Use compile as the classes are not provided by the system.
使用编译,因为系统未提供这些类。
On one hand you can use both v4 and v13 support packages . 一方面,您可以同时使用v4和v13支持软件包 。 Sometimes you have to.
有时您必须这样做。
For example android.support.v13.app.FragmentPagerAdapter
and android.support.v4.app.FragmentPagerAdapter
are similar but not identical : they don't use the same kind of fragments (native android.app.Fragment
vs support android.support.v4.app.Fragment
). 例如
android.support.v13.app.FragmentPagerAdapter
和android.support.v4.app.FragmentPagerAdapter
相似但不相同:它们不使用相同类型的片段(原生android.app.Fragment
与支持android.support.v4.app.Fragment
)。
So if you want to use a ViewPager
with native fragment you have to extend the v13 FragmentPagerAdapter
and set it on the ViewPager
(v4, there is only one). 因此,如果要将
ViewPager
与本机片段一起使用,则必须扩展v13 FragmentPagerAdapter
并将其设置在ViewPager
(v4,只有一个)。 Of course this will only work on v13+ devices. 当然,这仅适用于v13 +设备。
On the other hand you don't have to declare both library : the v13 support lib includes the v4, adding something like 另一方面,您不必声明两个库 :v13支持库包括v4,添加了类似
compile "com.android.support:support-v13:23.1.1"
in your build.gradle
gives you access to both v4 an v13 support classes. 在
build.gradle
,您可以访问v4和v13这两个支持类。
By the way, see Fragment or Support Fragment for more details about native vs support fragments. 顺便说一句,请参阅片段或支持片段以获取有关本机vs支持片段的更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.