Below are snippets of code mainly from Android Developer . There is also a very good example application / project.
Use ViewPage as a container for your layout, for example. Res / layout / activity_main.xml:
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" />
Add ABS ActionBar.TabListener to your class, add and extend FragmentPagerAdapter or FragmentStatePagerAdapter from the support library, for example:
public class TheDesertFoxActivity extends SherlockFragmentActivity implements ActionBar.TabListener { private AppSectionsPagerAdapter mAppSectionsPagerAdapter; private ViewPager mViewPager; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());
What is it. Separators will be placed by the ViewPager for you. You do not need to add them yourself.
ozbek
source share