Skip to content

Instantly share code, notes, and snippets.

@kunmi
Created January 1, 2018 22:55
Show Gist options
  • Save kunmi/9b4b55460827eba64a320c43826b8802 to your computer and use it in GitHub Desktop.
Save kunmi/9b4b55460827eba64a320c43826b8802 to your computer and use it in GitHub Desktop.
Code snippet for kunmii.blogspot.com Creating Dialog with Tabs : Android
public class CustomAdapter extends FragmentPagerAdapter {
List<Fragment> mFragmentCollection = new ArrayList<>();
List<String> mTitleCollection = new ArrayList<>();
public CustomAdapter(FragmentManager fm) {
super(fm);
}
public void addFragment(String title, Fragment fragment)
{
mTitleCollection.add(title);
mFragmentCollection.add(fragment);
}
//Needed for
@Override
public CharSequence getPageTitle(int position) {
return mTitleCollection.get(position);
}
@Override
public Fragment getItem(int position) {
return mFragmentCollection.get(position);
}
@Override
public int getCount() {
return mFragmentCollection.size();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment