I am trying to get my FragmentPagerAdapter to work, but the examples are a bit simplified for real life:
@Override public Object instantiateItem(final ViewGroup container, final int position) { final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); int resId = 0; switch (position) { case 0: resId = R.layout.favorites_fragment; break; case 1: resId = R.layout.nearby_list_fragment; break; default: throw new IllegalArgumentException("Index cant be mapped to fragement:" + position); } final View view = inflater.inflate(resId, null); viewPager.addView(view, 0); return view; }
Since I want to use Fragments, I already confused my this method, since the whole example could find inflating the view instead of creating a fragment there. How to do it?
PS: Im using ActionBarSherlock lib 4.1 ...
Thanks Jens
source share