如何为swipeView片段添加标签?
这是主要活动的onCreate方法,其中初始化了两个片段:
MyFragmentPagerAdapter pagerAdapter;
/**
* The pager adapter, which provides the pages to the view pager widget.
*/
ViewPager pager = null;
MyFragmentPagerAdapter adapter = null;
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
this.setContentView(R.layout.activity_main);
// Instantiate a ViewPager
this.pager = (ViewPager) this.findViewById(R.id.pager);
// Set a custom animation
this.pager.setPageTransformer(true, new DepthPagerTransformer());
// Create an adapter with the fragments we show on the ViewPager
this.adapter = new MyFragmentPagerAdapter(
getSupportFragmentManager());
this.adapter.addFragment(InActivityPageFragment.newInstance(getResources()
.getColor(R.color.red), 0));
this.adapter.addFragment(ListActivitiesPageFragment.newInstance(getResources()
.getColor(R.color.white), 1));
this.pager.setAdapter(adapter);
}