Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ViewPager inside ListView

Is there a way to add a viewpager as a listview item?

I want to add it as a "header" on top of my listview before all real list items follow. I tried using addHeaderView() or declaring multiple view types in my list adapter, however, the viewpager never shows up whatever way I try.

Has anyone done something similar? Help!

like image 759
dnkoutso Avatar asked Dec 29 '11 23:12

dnkoutso


2 Answers

Do not use wrap_content, try to calculate and set ViewPager size programmatically and then add ViewPager as a header of ListView.

like image 152
Wayne Avatar answered Oct 28 '22 15:10

Wayne


Quoting Dianne Hackborn, ViewPager is "just not intended to be used as an item in a list"

like image 32
CommonsWare Avatar answered Oct 28 '22 17:10

CommonsWare