3
我試圖讓我的FragmentPagerAdapter工作,但這些例子有點簡單的現實生活:FragmentPagerAdapter instantiateItem使用Fragments?
@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;
}
因爲我想用碎片IM已經弄得我這個方法,所有的例子我能找到的膨脹一個視圖,而不是在那裏創建片段。這個怎麼做 ?
PS:IM使用ActionBarSherlock LIB 4.1 ...
感謝, 延
Arg,我錯過了這個方法!它現在工作!感謝尼古拉 – Kitesurfer