私は FragmentPagerAdapter を機能させようとしていますが、例は実際には少し簡単です:
@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;
}
Fragments を使用したいので、このメソッドを既に混乱させています。すべての例で、フラグメントを作成する代わりにビューを膨張させることができます。これを行う方法 ?
PS: ActionBarSherlock lib 4.1 を使用しています...
ありがとう、イェンス