Search in sources :

Example 6 with PageNavigationView

use of me.majiajie.pagerbottomtabstrip.PageNavigationView in project PagerBottomTabStrip by tyzlmjj.

the class SpecialActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_special);
    PageNavigationView tab = findViewById(R.id.tab);
    NavigationController navigationController = tab.custom().addItem(newItem(R.drawable.ic_restore_gray_24dp, R.drawable.ic_restore_teal_24dp, "Recents")).addItem(newItem(R.drawable.ic_favorite_gray_24dp, R.drawable.ic_favorite_teal_24dp, "Favorites")).addItem(newRoundItem(R.drawable.ic_nearby_gray_24dp, R.drawable.ic_nearby_teal_24dp, "Nearby")).addItem(newItem(R.drawable.ic_favorite_gray_24dp, R.drawable.ic_favorite_teal_24dp, "Favorites")).addItem(newItem(R.drawable.ic_restore_gray_24dp, R.drawable.ic_restore_teal_24dp, "Recents")).build();
    ViewPager viewPager = findViewById(R.id.viewPager);
    viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), navigationController.getItemCount()));
    // 自动适配ViewPager页面切换
    navigationController.setupWithViewPager(viewPager);
}
Also used : NavigationController(me.majiajie.pagerbottomtabstrip.NavigationController) PageNavigationView(me.majiajie.pagerbottomtabstrip.PageNavigationView) MyViewPagerAdapter(me.majiajie.pagerbottomtabstriptest.other.MyViewPagerAdapter) ViewPager(androidx.viewpager.widget.ViewPager)

Example 7 with PageNavigationView

use of me.majiajie.pagerbottomtabstrip.PageNavigationView in project PagerBottomTabStrip by tyzlmjj.

the class BehaviorActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_behavior);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    PageNavigationView pageBottomTabLayout = findViewById(tab);
    mNavigationController = pageBottomTabLayout.material().addItem(R.drawable.ic_restore_teal_24dp, "Recents").addItem(R.drawable.ic_favorite_teal_24dp, "Favorites").addItem(R.drawable.ic_nearby_teal_24dp, "Nearby").build();
    ViewPager viewPager = findViewById(R.id.viewPager);
    viewPager.setAdapter(new TestViewPagerAdapter(getSupportFragmentManager()));
    mNavigationController.setupWithViewPager(viewPager);
}
Also used : PageNavigationView(me.majiajie.pagerbottomtabstrip.PageNavigationView) ViewPager(androidx.viewpager.widget.ViewPager) Toolbar(androidx.appcompat.widget.Toolbar)

Example 8 with PageNavigationView

use of me.majiajie.pagerbottomtabstrip.PageNavigationView in project PagerBottomTabStrip by tyzlmjj.

the class CustomActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_horizontal);
    PageNavigationView tab = findViewById(R.id.tab);
    NavigationController navigationController = tab.custom().addItem(newItem(R.drawable.ic_restore_gray_24dp, R.drawable.ic_restore_teal_24dp, "Recents")).addItem(newItem(R.drawable.ic_favorite_gray_24dp, R.drawable.ic_favorite_teal_24dp, "Favorites")).addItem(newItem(R.drawable.ic_nearby_gray_24dp, R.drawable.ic_nearby_teal_24dp, "Nearby")).build();
    ViewPager viewPager = findViewById(R.id.viewPager);
    viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), navigationController.getItemCount()));
    // 自动适配ViewPager页面切换
    navigationController.setupWithViewPager(viewPager);
    // 设置消息数
    navigationController.setMessageNumber(1, 8);
    // 设置显示小圆点
    navigationController.setHasMessage(0, true);
}
Also used : NavigationController(me.majiajie.pagerbottomtabstrip.NavigationController) PageNavigationView(me.majiajie.pagerbottomtabstrip.PageNavigationView) MyViewPagerAdapter(me.majiajie.pagerbottomtabstriptest.other.MyViewPagerAdapter) ViewPager(androidx.viewpager.widget.ViewPager)

Aggregations

ViewPager (androidx.viewpager.widget.ViewPager)8 PageNavigationView (me.majiajie.pagerbottomtabstrip.PageNavigationView)8 MyViewPagerAdapter (me.majiajie.pagerbottomtabstriptest.other.MyViewPagerAdapter)6 NavigationController (me.majiajie.pagerbottomtabstrip.NavigationController)3 Toolbar (androidx.appcompat.widget.Toolbar)2 OnTabItemSelectedListener (me.majiajie.pagerbottomtabstrip.listener.OnTabItemSelectedListener)2 OnlyTextTab (me.majiajie.pagerbottomtabstriptest.custom.OnlyTextTab)1