First of all i am a newbie.I am developing an app Which has a viewpager and fragments in it,but later i decided to put lists in the fragments so i had to change them into Listfragments so i had to change the adpaters a bit,and now its not working and now i am totally confused that which adapter should extend what.
首先,我是一个新手。我正在开发一个应用程序,其中有一个viewpager和片段,但后来我决定将列表放入片段,所以我不得不将它们更改为Listfragments,所以我不得不改变adpaters,现在它不工作,现在我完全混淆哪个适配器应该扩展什么。
initially i had a Viewpager adapter which extends fragmentpageadapter(should it extend any kind of listfragment pageadapter)
最初我有一个Viewpager适配器,它扩展了fragmentpageadapter(它应该扩展任何类型的listfragment pageadapter)
and i have another customadapter which extends base adapter(custom adapter because i want a custom listview in the fragments). thanx in advance.
我有另一个customadapter扩展基本适配器(自定义适配器,因为我想在片段中的自定义列表视图)。提前。
1 个解决方案
#1
2
ListView
(and by extension ListFragment
) doesn't care what your adapter is as long as it conforms to the ListAdapter
interface, which yours does if it extends BaseAdapter
. There are some other Adapter implementations in the SDK for simple use cases, you can explore them on your own or look at the ApiDemos sample application.
ListView(以及扩展名为ListFragment)并不关心你的适配器是什么,只要它符合ListAdapter接口,如果扩展BaseAdapter你就会这样做。 SDK中有一些其他适配器实现用于简单的用例,您可以自己探索它们或查看ApiDemos示例应用程序。
Similarly, ViewPager
only cares that you provide it something that extends PagerAdapter
, which FragmentPagerAdapter
does.
同样,ViewPager只关心你为它提供扩展PagerAdapter的东西,FragmentPagerAdapter就是这样做的。
#1
2
ListView
(and by extension ListFragment
) doesn't care what your adapter is as long as it conforms to the ListAdapter
interface, which yours does if it extends BaseAdapter
. There are some other Adapter implementations in the SDK for simple use cases, you can explore them on your own or look at the ApiDemos sample application.
ListView(以及扩展名为ListFragment)并不关心你的适配器是什么,只要它符合ListAdapter接口,如果扩展BaseAdapter你就会这样做。 SDK中有一些其他适配器实现用于简单的用例,您可以自己探索它们或查看ApiDemos示例应用程序。
Similarly, ViewPager
only cares that you provide it something that extends PagerAdapter
, which FragmentPagerAdapter
does.
同样,ViewPager只关心你为它提供扩展PagerAdapter的东西,FragmentPagerAdapter就是这样做的。