在布局底部声明tab
然后
mTabs.add(ChatsFragment.newInstance("",""));
mTabs.add(ContactsFragment.newInstance("",""));
mTabs.add(DiscoverFragment.newInstance("",""));
mTabs.add(AboutMeFragment.newInstance("",""));
mAdapter=newFragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public intgetCount() {
returnmTabs.size();
}
@Override
publicFragmentgetItem(intarg0) {
returnmTabs.get(arg0);
}
};
public staticChatsFragmentnewInstance(String param1,String param2) {
ChatsFragment fragment =newChatsFragment();
Bundle args =newBundle();
args.putString(ARG_PARAM1,param1);
args.putString(ARG_PARAM2,param2);
fragment.setArguments(args);
returnfragment;
}