Giter Site home page Giter Site logo

amirahmadadibi / bottomnavigation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jaisonfdo/bottomnavigation

1.0 1.0 0.0 101 KB

A sample app for Bottom Navigation View with ViewPager in Android

Home Page: http://droidmentor.com/bottomnavigationview-with-viewpager-android/

Java 100.00%

bottomnavigation's Introduction

BottomNavigation

A sample app for Bottom Navigation View with ViewPager ScreenShot

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

bottomnavigation's People

Contributors

jaisonfdo avatar

Stargazers

Hadi Salimi avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.