I want to create ViewPager with this tutorial:
ViewPager example
But i don’t know how can I use my own activity on First layout or Second layout.
This is function which change layout:
private void setTab(){
_mViewPager.setOnPageChangeListener(new OnPageChangeListener(){
@Override
public void onPageScrollStateChanged(int position) {}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {}
@Override
public void onPageSelected(int position) {
// TODO Auto-generated method stub
switch(position){
case 0:
findViewById(R.id.first_tab).setVisibility(View.VISIBLE);
findViewById(R.id.second_tab).setVisibility(View.INVISIBLE);
break;
case 1:
findViewById(R.id.first_tab).setVisibility(View.INVISIBLE);
findViewById(R.id.second_tab).setVisibility(View.VISIBLE);
break;
}
}
});
}
That is not an especially good sample. Please consider using
PagerTitleStrip,PagerTabStrip(both in the Android Support package, along withViewPager) or one of the classes from ViewPagerIndicator.ViewPagerdoes not hold activities. It holds views, optionally managed by fragments. The concept of having activities inside of other activities is not recommended and is officially deprecated.