本文整理汇总了Java中com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems类的典型用法代码示例。如果您正苦于以下问题:Java FragmentPagerItems类的具体用法?Java FragmentPagerItems怎么用?Java FragmentPagerItems使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FragmentPagerItems类属于com.ogaclejapan.smarttablayout.utils.v4包,在下文中一共展示了FragmentPagerItems类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems; //导入依赖的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.FragmentPagerItems; //导入依赖的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.FragmentPagerItems; //导入依赖的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.FragmentPagerItems; //导入依赖的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.FragmentPagerItems; //导入依赖的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.FragmentPagerItems; //导入依赖的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.FragmentPagerItems; //导入依赖的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.FragmentPagerItems; //导入依赖的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.FragmentPagerItems; //导入依赖的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: onCreate
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initToolbar();
SPUtils.init(getApplicationContext());
viewPager = (ViewPager) findViewById(R.id.viewPager);
viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab);
fragmentPagerItems = new FragmentPagerItems(this);
location = new Location(MainActivity.this,handler);
location.location();
getCityList();
addList();
}
示例11: getAdapter
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems; //导入依赖的package包/类
public NavFragmentPagerItemAdapter getAdapter() {
final FragmentPagerItems.Creator itemCreator = FragmentPagerItems.with(getActivity());
itemCreator.add(
"k1",
UltimateSwipeRefreshFragment.class,
UltimateSwipeRefreshFragment.getBundle()
);
itemCreator.add(
"k2",
UltimateSwipeRefreshFragment.class,
UltimateSwipeRefreshFragment.getBundle()
);
itemCreator.add(
"k3",
UltimateSwipeRefreshFragment.class,
UltimateSwipeRefreshFragment.getBundle()
);
itemCreator.add(
"k4",
UltimateSwipeRefreshFragment.class,
UltimateSwipeRefreshFragment.getBundle()
);
return new NavFragmentPagerItemAdapter(getChildFragmentManager(), getNavigationManager(), itemCreator.create());
}
示例12: initializeViewPager
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems; //导入依赖的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);
}
示例13: configViewPager
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems; //导入依赖的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);
}
示例14: onCreate
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems; //导入依赖的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);
}
示例15: onCreate
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_direction);
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("方向控制");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// ViewGroup tab = (ViewGroup) findViewById(R.id.tab);
// tab.addView(LayoutInflater.from(this).inflate(demo.layoutResId, tab, false));
final ViewPager viewPager = (NoScrollViewPager) findViewById(R.id.viewpager);
final SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab);
// demo.setup(viewPagerTab);
FragmentPagerItems pages = new FragmentPagerItems(this);
pages.add(FragmentPagerItem.of(mCharSequences[0], GravitySensorFragment.class));
pages.add(FragmentPagerItem.of(mCharSequences[1], DirectionFragment.class));
pages.add(FragmentPagerItem.of(mCharSequences[2], JoyStickFragment.class));
FragmentStatePagerItemAdapter adapter = new FragmentStatePagerItemAdapter(
getSupportFragmentManager(), pages);
viewPager.setAdapter(adapter);
viewPagerTab.setViewPager(viewPager);
}