public class One extends Fragment {
private List<Fragment> list = new ArrayList<Fragment>();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.one, null);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ViewPager vp = (ViewPager) getView().findViewById(R.id.one_vp);
list.add(new FragOne());//子fragment
list.add(new FragTwo());//子fragment
VpAdapter adapter = new VpAdapter(getChildFragmentManager(), list);
vp.setAdapter(adapter);
}
}
如此实现