Search in sources :

Example 1 with SViewPager

use of com.shizhefei.view.viewpager.SViewPager in project ViewPagerIndicator by LuckyJayce.

the class TabMainActivity method onCreate.

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.activity_tabmain);
    SViewPager viewPager = (SViewPager) findViewById(R.id.tabmain_viewPager);
    indicator = (FixedIndicatorView) findViewById(R.id.tabmain_indicator);
    indicator.setOnTransitionListener(new OnTransitionTextListener().setColor(Color.RED, Color.GRAY));
    //这里可以添加一个view,作为centerView,会位于Indicator的tab的中间
    centerView = getLayoutInflater().inflate(R.layout.tab_main_center, indicator, false);
    indicator.setCenterView(centerView);
    centerView.setOnClickListener(onClickListener);
    indicatorViewPager = new IndicatorViewPager(indicator, viewPager);
    indicatorViewPager.setAdapter(new MyAdapter(getSupportFragmentManager()));
    // 禁止viewpager的滑动事件
    viewPager.setCanScroll(false);
    // 设置viewpager保留界面不重新加载的页面数量
    viewPager.setOffscreenPageLimit(4);
}
Also used : IndicatorViewPager(com.shizhefei.view.indicator.IndicatorViewPager) SViewPager(com.shizhefei.view.viewpager.SViewPager) OnTransitionTextListener(com.shizhefei.view.indicator.transition.OnTransitionTextListener)

Aggregations

IndicatorViewPager (com.shizhefei.view.indicator.IndicatorViewPager)1 OnTransitionTextListener (com.shizhefei.view.indicator.transition.OnTransitionTextListener)1 SViewPager (com.shizhefei.view.viewpager.SViewPager)1