本文整理汇总了Java中com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter类的典型用法代码示例。如果您正苦于以下问题:Java FragmentPagerItemAdapter类的具体用法?Java FragmentPagerItemAdapter怎么用?Java FragmentPagerItemAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FragmentPagerItemAdapter类属于com.ogaclejapan.smarttablayout.utils.v4包,在下文中一共展示了FragmentPagerItemAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
private void init() {
mPagerTab = (SmartTabLayout) findViewById(R.id.viewpagerTab);
initPagerTab();
mPager = (ViewPager) findViewById(R.id.mainPager);
FragmentPagerItems pages = FragmentPagerItems.with(mActivity)
.add(R.string.tab_hi, HiTalkFragment.class)
.add(R.string.tab_message, MessageFragment.class)
.add(R.string.tab_address, AddressFragment.class)
.add(R.string.tab_blackboard, BlackboardFragment.class)
.add(R.string.tab_me, MeFragment.class)
.create();
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
mActivity.getSupportFragmentManager(), pages);
mPager.setOffscreenPageLimit(5);
mPager.setAdapter(adapter);
mPagerTab.setViewPager(mPager);
}
示例2: onViewCreated
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ViewPager mViewPager = (ViewPager) view.findViewById(R.id.vp);
FragmentPagerItems pages = new FragmentPagerItems(getActivity());
final int page = FragmentPagerItem.getPosition(getArguments());
for (int i = 0; i < 5; i++) {
Bundle bundle = new Bundle();
bundle.putInt("page", page);
bundle.putInt("position", i);
pages.add(FragmentPagerItem.of(String.valueOf(i), DemoFragment.class, bundle));
}
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getChildFragmentManager(), pages); //Fragment嵌套Fragment时,要用getChildFragmentManager
mViewPager.setAdapter(adapter);
mViewPager.setOffscreenPageLimit(2);
mViewPager.setPageMargin(30);
final MainActivity mainActivity = (MainActivity) getActivity();
mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
mainActivity.pageScrolled(page, position, positionOffset);
}
});
}
示例3: initview
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
private void initview() {
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getActivity().getSupportFragmentManager(), FragmentPagerItems.with(getActivity())
.add(R.string.a, MainFragment.class)
.add(R.string.b, SpecialFragment.class)
.add(R.string.c, FriendsFragment.class)
.create());
ViewPager viewPager = (ViewPager) rootView.findViewById(R.id.viewpager);
viewPager.setOffscreenPageLimit(2);
viewPager.setAdapter(adapter);
SmartTabLayout viewPagerTab = (SmartTabLayout) rootView.findViewById(R.id.viewpagertab);
viewPagerTab.setViewPager(viewPager);
}
示例4: onCreateView
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home, container, false);
ViewPager viewPager = (ViewPager) view.findViewById(R.id.fragment_home_pager);
SmartTabLayout smartTabLayout = (SmartTabLayout) view.findViewById(R.id.fragment_home_tab_smart);
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getActivity().getSupportFragmentManager(), FragmentPagerItems.with(getContext())
.add("首页", WatchFragment.class)
.add("新闻", FreshNewsFragment.class)
.create());
ButterKnife.bind(this, view);
viewPager.setAdapter(adapter);
smartTabLayout.setViewPager(viewPager);
return view;
}
示例5: onCreateView
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_personal_home, container, false);
ViewPager viewPager = (ViewPager) view.findViewById(R.id.fragment_personal_home_pager);
SmartTabLayout smartTabLayout = (SmartTabLayout) view.findViewById(R.id.fragment_personal_home_tab_smart);
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getActivity().getSupportFragmentManager(), FragmentPagerItems.with(getContext())
.add("个人成绩", ScoreFragment.class)
.add("图表分析", ListViewMultiChartFragment.class)
.create());
ButterKnife.bind(view);
viewPager.setAdapter(adapter);
smartTabLayout.setViewPager(viewPager);
return view;
}
示例6: setupTabView
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
protected void setupTabView() {
final LayoutInflater inflater = LayoutInflater.from(this);
final int[] tabIcons = {R.drawable.ic_recommended, R.drawable.ic_topics, R.drawable.ic_wiki, R.drawable.ic_me};
FragmentPagerItems pages = FragmentPagerItems.with(this)
.add(R.string.recommended, RecommendedFragment.class)
.add(R.string.topics, TopicsFragment.class)
.add(R.string.wiki, WikiFragment.class)
.add(R.string.me, MeFragment.class)
.create();
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getSupportFragmentManager(),
pages);
viewPager.setOffscreenPageLimit(pages.size());
viewPager.setAdapter(adapter);
viewpagerTab.setCustomTabView(new SmartTabLayout.TabProvider() {
@Override
public View createTabView(ViewGroup container, int position, PagerAdapter pagerAdapter) {
View view = inflater.inflate(R.layout.custom_tab_icon, container, false);
ImageView iconView = (ImageView) view.findViewById(R.id.iv_icon);
iconView.setBackgroundResource(tabIcons[position % tabIcons.length]);
return view;
}
});
viewpagerTab.setViewPager(viewPager);
}
示例7: lazyLoad
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
@Override
protected void lazyLoad() {
if (!isPrepared || !isVisible || adapterHasCreated) {
return;
}
FragmentPagerItems pages = FragmentPagerItems.with(getActivity())
.add(R.string.recent, TopicFragment.class, getTopicTypeBundle(TOPIC_TYPE_RECENT))
.add(R.string.vote, TopicFragment.class, getTopicTypeBundle(TOPIC_TYPE_VOTE))
.add(R.string.jobs, TopicFragment.class, getTopicTypeBundle(TOPIC_TYPE_JOBS))
.create();
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getChildFragmentManager(),
pages);
viewPager.setOffscreenPageLimit(pages.size());
viewPager.setAdapter(adapter);
viewpagerTab.setViewPager(viewPager);
adapterHasCreated = true;
}
示例8: onCreate
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mViewPager = (VerticalViewPager) this.findViewById(R.id.viewpager);
mTabLayout = (ChangeTabLayout) this.findViewById(R.id.tabLayout);
pages = new FragmentPagerItems(this);
mViewPager.setOffscreenPageLimit(title.length);
for (String titleResId : title) {
pages.add(FragmentPagerItem.of(titleResId, PageFragment.class));
}
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages);
mViewPager.setAdapter(adapter);
mTabLayout.setViewPager(mViewPager, icon, null);
mTabLayout.setOnTabClickListener(new ChangeTabLayout.OnTabClickListener() {
@Override
public void onTabClicked(int position) {
Log.d(TAG, "点击了" + position);
}
});
}
示例9: initView
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
@Override
public void initView(View view) {
FragmentPagerItems.Creator creator = FragmentPagerItems.with(getActivity());
for (int i = 0, tabCount = getTabCount(); i < tabCount; i++) {
creator.add(getTabTitle(i), getViewPagerItemFragmentClass());
}
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getChildFragmentManager(), creator.create());
mViewPager.setAdapter(adapter);
mViewPager.setOffscreenPageLimit(getTabCount());
mSmartTabLayout.setViewPager(mViewPager);
}
示例10: initializeViewPager
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
private void initializeViewPager() {
adapter = new FragmentPagerItemAdapter(
getSupportFragmentManager(), FragmentPagerItems.with(this)
.add(R.string.home, CultFragment.class)
.add(R.string.more, CultFragment.class)
.create());
if (viewPager == null || smartTabLayout == null) {
return;
}
viewPager.setAdapter(adapter);
smartTabLayout.setViewPager(viewPager);
}
示例11: configViewPager
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
/**
* Configura o ViewPager da Activity utilizando
* a biblioteca SmartTabLayout.
*/
private void configViewPager() {
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getSupportFragmentManager(), FragmentPagerItems.with(this)
.add("", UserDataFragment.class)
.add("", UserSpecsFragment.class)
.create());
viewPager.setAdapter(adapter);
smartTabLayout.setViewPager(viewPager);
}
示例12: notifyUser
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
/**
* Após configurar o usuário, é necessario informar ao segundo fragment
* as suas informações, este método é utilizado para esconder o teclado,
* mover a página para a direita e declarar os dados do usuário.
* @param user
*/
public void notifyUser(User user) {
hideKeyboard();
slideToNextPage();
Fragment page = ((FragmentPagerItemAdapter) viewPager.getAdapter()).getPage(1);
if (page != null && page instanceof UserSpecsFragment) {
((UserSpecsFragment) page).notifyUser(user);
}
}
示例13: onCreate
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), FragmentPagerItems.with(this)
.add("Photos", MainFragment.class)
.create());
mViewPager.setAdapter(adapter);
mTab.setViewPager(mViewPager);
//mTab.setOnPageChangeListener(mPageChangeListener);
}
示例14: onCreate
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
vp = (ViewPager)findViewById(R.id.viewpager);
smartTab = (SmartTabLayout)findViewById(R.id.viewpagertab);
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getSupportFragmentManager(), FragmentPagerItems.with(this)
.add(R.string.News, SectionFragment.class)
.add(R.string.ThisWeek, SectionFragment.class)
.add(R.string.Leaders, SectionFragment.class)
.add(R.string.Letters, SectionFragment.class)
.add(R.string.Briefing, SectionFragment.class)
.add(R.string.US, SectionFragment.class)
.add(R.string.Americas, SectionFragment.class)
.add(R.string.Asia, SectionFragment.class)
.add(R.string.China, SectionFragment.class)
.add(R.string.MEAA, SectionFragment.class)
.add(R.string.Europe, SectionFragment.class)
.add(R.string.Britain, SectionFragment.class)
.add(R.string.International, SectionFragment.class)
.add(R.string.Business, SectionFragment.class)
.add(R.string.Finance, SectionFragment.class)
.add(R.string.Science, SectionFragment.class)
.add(R.string.Books, SectionFragment.class)
.add(R.string.Obituary, SectionFragment.class)
.add(R.string.Figures, SectionFragment.class)
.create());
vp.setAdapter(adapter);
smartTab.setViewPager(vp);
}
示例15: configViewPager
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter; //导入依赖的package包/类
private void configViewPager() {
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getSupportFragmentManager(), FragmentPagerItems.with(this)
.add(R.string.tab_1, BaseFragment.class)
.add(R.string.tab_2, BaseFragment.class)
.add(R.string.tab_3, BaseFragment.class)
.add(R.string.tab_4, BaseFragment.class)
.create());
viewPager.setAdapter(adapter);
smartTabLayout.setViewPager(viewPager);
}