2017-01-27 17:10:50 +00:00
|
|
|
package com.topjohnwu.magisk.adapters;
|
|
|
|
|
2017-01-28 16:20:43 +00:00
|
|
|
|
|
|
|
import android.support.v4.app.Fragment;
|
|
|
|
import android.support.v4.app.FragmentManager;
|
|
|
|
import android.support.v4.app.FragmentPagerAdapter;
|
2017-01-27 17:10:50 +00:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class TabFragmentAdapter extends FragmentPagerAdapter {
|
|
|
|
|
|
|
|
private List<Fragment> fragmentList;
|
|
|
|
private List<String> titleList;
|
|
|
|
|
|
|
|
public TabFragmentAdapter(FragmentManager fm) {
|
|
|
|
super(fm);
|
|
|
|
fragmentList = new ArrayList<>();
|
|
|
|
titleList = new ArrayList<>();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Fragment getItem(int position) {
|
|
|
|
return fragmentList.get(position);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCount() {
|
|
|
|
return fragmentList.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public CharSequence getPageTitle(int position) {
|
|
|
|
return titleList.get(position);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addTab(Fragment fragment, String title) {
|
|
|
|
fragmentList.add(fragment);
|
|
|
|
titleList.add(title);
|
|
|
|
}
|
|
|
|
}
|