Search code examples
androidandroid-fragmentsandroid-viewpagerandroid-listfragmentandroid-adapter

what adapters should i use for listfragment and what class they should extend


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.

initially i had a Viewpager adapter which extends fragmentpageadapter(should it extend any kind of 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.


Solution

  • 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.

    Similarly, ViewPager only cares that you provide it something that extends PagerAdapter, which FragmentPagerAdapter does.