Search in sources :

Example 1 with DummyPagerTitleView

use of net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.DummyPagerTitleView in project MagicIndicator by hackware1993.

the class NoTabOnlyIndicatorExampleActivity method initMagicIndicator1.

private void initMagicIndicator1() {
    MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator1);
    magicIndicator.setBackgroundColor(Color.LTGRAY);
    CommonNavigator commonNavigator = new CommonNavigator(this);
    commonNavigator.setAdjustMode(true);
    commonNavigator.setAdapter(new CommonNavigatorAdapter() {

        @Override
        public int getCount() {
            return mDataList == null ? 0 : mDataList.size();
        }

        @Override
        public IPagerTitleView getTitleView(Context context, final int index) {
            return new DummyPagerTitleView(context);
        }

        @Override
        public IPagerIndicator getIndicator(Context context) {
            LinePagerIndicator indicator = new LinePagerIndicator(context);
            float lineHeight = context.getResources().getDimension(R.dimen.small_navigator_height);
            indicator.setLineHeight(lineHeight);
            indicator.setColors(Color.parseColor("#40c4ff"));
            return indicator;
        }
    });
    magicIndicator.setNavigator(commonNavigator);
    ViewPagerHelper.bind(magicIndicator, mViewPager);
}
Also used : Context(android.content.Context) CommonNavigator(net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator) CommonNavigatorAdapter(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter) IPagerIndicator(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator) IPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView) DummyPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.DummyPagerTitleView) MagicIndicator(net.lucode.hackware.magicindicator.MagicIndicator) LinePagerIndicator(net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator)

Example 2 with DummyPagerTitleView

use of net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.DummyPagerTitleView in project MagicIndicator by hackware1993.

the class NoTabOnlyIndicatorExampleActivity method initMagicIndicator2.

private void initMagicIndicator2() {
    MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator2);
    CommonNavigator commonNavigator = new CommonNavigator(this);
    commonNavigator.setAdjustMode(true);
    commonNavigator.setAdapter(new CommonNavigatorAdapter() {

        @Override
        public int getCount() {
            return mDataList == null ? 0 : mDataList.size();
        }

        @Override
        public IPagerTitleView getTitleView(Context context, final int index) {
            return new DummyPagerTitleView(context);
        }

        @Override
        public IPagerIndicator getIndicator(Context context) {
            TriangularPagerIndicator indicator = new TriangularPagerIndicator(context);
            indicator.setReverse(true);
            float smallNavigatorHeight = context.getResources().getDimension(R.dimen.small_navigator_height);
            indicator.setLineHeight(UIUtil.dip2px(context, 2));
            indicator.setTriangleHeight((int) smallNavigatorHeight);
            indicator.setLineColor(Color.parseColor("#e94220"));
            return indicator;
        }
    });
    magicIndicator.setNavigator(commonNavigator);
    ViewPagerHelper.bind(magicIndicator, mViewPager);
}
Also used : Context(android.content.Context) CommonNavigator(net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator) CommonNavigatorAdapter(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter) IPagerIndicator(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator) IPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView) DummyPagerTitleView(net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.DummyPagerTitleView) MagicIndicator(net.lucode.hackware.magicindicator.MagicIndicator) TriangularPagerIndicator(net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.TriangularPagerIndicator)

Aggregations

Context (android.content.Context)2 MagicIndicator (net.lucode.hackware.magicindicator.MagicIndicator)2 CommonNavigator (net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator)2 CommonNavigatorAdapter (net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter)2 IPagerIndicator (net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator)2 IPagerTitleView (net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView)2 DummyPagerTitleView (net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.DummyPagerTitleView)2 LinePagerIndicator (net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator)1 TriangularPagerIndicator (net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.TriangularPagerIndicator)1