0

I want to place a ListView (ListFragment) inside a ViewPager using a FragmentPagerAdapter. But the ListViews scrolling functionallity seems to be disabled when doing this (I cant scroll up and down). Here is my code:

main.xml

<include layout="@layout/prisniveau_info" />

<android.support.v4.view.ViewPager
    android:id="@+id/pager" 
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <android.support.v4.view.PagerTitleStrip
        android:id="@+id/pager_title_strip"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:layout_gravity="top"
        android:background="@color/light_gray"
        android:paddingBottom="5dp"
        android:paddingTop="5dp"
        android:textColor="#fff" />
</android.support.v4.view.ViewPager>

adapter:

 public class MyAdapter extends android.support.v4.app.FragmentPagerAdapter
     {
public MyAdapter(android.support.v4.app.FragmentManager fm)
{
     super(fm);
}
@Override
public int getCount()
{
    return 2;
}       
@Override
public Fragment getItem(int position)
{
    Fragment fragment = null;
    if(position==0)
    {
        fragment = new MyListFragment();                
    }
    else if(position==1)
    {
        fragment = new MyMapFragment();
    }
    return fragment;
}       
@Override
public CharSequence getPageTitle(int position)
{
    switch (position)
    {
        case 0:
        return  getString(R.string.title_list).toUpperCase(Locale.getDefault());
        case 1:
            return getString(R.string.title_map).toUpperCase(Locale.getDefault());
        }
        return null;
    }       
    public String getFragmentTag(int index)
    {
         return "android:switcher:" + R.id.pager + ":" + index;
    }
}

Is it possible to make the ListView scrollable inside a ViewPager?

GrIsHu
  • 29,068
  • 10
  • 64
  • 102
Kasper Finne Nielsen
  • 2,086
  • 2
  • 17
  • 28

1 Answers1

0

i have found a solution here. There might be the problem in handling touch events properly for a HorizontalScrollView inside a regular ScrollView, but the solution to that problem may seems to apply to this one too.

Community
  • 1
  • 1
Nirav Tukadiya
  • 3,367
  • 1
  • 18
  • 36