Note that there are some explanatory texts on larger screens.

plurals
  1. POViewpager inside fragment loses focus
    primarykey
    data
    text
    <p>I have a viewpager inside a fragment, I can scroll through the pages fine. When I add a new fragment to the back stack the new fragment shows as expected in the old fragments container. Once I press back the old fragment is displayed however the view pager is no longer working, instead the focus switches to the sliding menu(the fragment layout I commit to is the central layout in feinsteins menu) and when I swipe the sliding menu opens up instead of moving to the next page in the viewpager. Why might this be?</p> <p>Here is my Viewpager adapter which is subclassed inside the fragment atm</p> <pre><code> static class SamplePagerAdapter extends PagerAdapter { private static int[] sDrawables = { R.drawable.main1, R.drawable.main3, R.drawable.main2, R.drawable.main3, R.drawable.main4, R.drawable.main5 }; @Override public int getCount() { return sDrawables.length; } @Override public View instantiateItem(ViewGroup container, int position) { ImageView imageView = new ImageView(container.getContext()); imageView.setImageResource(sDrawables[position]); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //thiscalls back to the Fragmentctivity and switches to the new fragment, problems arise when I go back to this fragment and the viewpager wont swipe to next page ((LeftAndRightActivity) cx).switchFragmentTo(12); } }); // Now just add ImageView to ViewPager and return it container.addView(imageView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); return imageView; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View) object); } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } } </code></pre> <p>Here is onCreateView() of my fragment which contains the viewpager( I am actually using the PullToRefresh Viewpager by ChrisBanes)</p> <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) return null; if (v != null) return v; v = inflater.inflate(R.layout.savescreenlayout, container, false); mPullToRefreshViewPager = (PullToRefreshBase) v .findViewById(R.id.pull_refresh_viewpager); mPullToRefreshViewPager.setOnRefreshListener(this); mPullToRefreshViewPager.setMode(Mode.PULL_FROM_END); vp = (ViewPager) mPullToRefreshViewPager.getRefreshableView(); vp.setAdapter(new SamplePagerAdapter()); return v; } </code></pre> <p>The first time my Fragment with the viewpager is commited its fine, its just when I come back from any other fragment that the viewpager stops paging and the sliding menu opens up instead. thanks for any help in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload