Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
B

BottomNavigation

> 编程语言
Open source

A sample app for Bottom Navigation View with ViewPager in Android

100 stars0 likes1 views
WebsiteGitHub

About

A sample app for Bottom Navigation View with ViewPager in Android

BottomNavigation

A sample app for Bottom Navigation View with ViewPager

For connecting BottomNavigationView with ViewPager, you need to follow thesesteps

  1. First, you need to create an application with latest Design Support Library(25) to your build.gradle to use BottomNavigationView.

  2. Then add all the necessary resources ( color, drawable’s ) to the resource directory.

  3. Create a view with ViewPager and BottomNavigationView

  4. Create necessary fragments for each tab on the viewpager.

  5. Then setup the viewpager using fragments and viewpager adapter.

  6. Add OnNavigationItemSelectedListener for BottomNavigationView, and override OnNavigationItemSelected method with the relevant action.

  7. Once done with the previous step add OnPageChangeListener to the ViewPager and override the PageSelected method. The magic happens here, the following code selects the relevant item in the BottomNavigationView.

@Override public void onPageSelected(int position) { if (prevMenuItem != null) { prevMenuItem.setChecked(false); } else { bottomNavigationView.getMenu().getItem(0).setChecked(false); }

    bottomNavigationView.getMenu().getItem(position).setChecked(true);
    prevMenuItem = bottomNavigationView.getMenu().getItem(position);
}

For more information, check out my detailed guide here : http://droidmentor.com/bottomnavigationview-with-viewpager-android

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javaandroidbottomnavigationbottomnavigationviewfragments

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言