Created
January 1, 2018 22:55
-
-
Save kunmi/9b4b55460827eba64a320c43826b8802 to your computer and use it in GitHub Desktop.
Code snippet for kunmii.blogspot.com Creating Dialog with Tabs : Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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