Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement onitemclick listener? #63

Open
mugabi0978 opened this issue May 21, 2017 · 3 comments
Open

How to implement onitemclick listener? #63

mugabi0978 opened this issue May 21, 2017 · 3 comments

Comments

@mugabi0978
Copy link

How can I set my own fragment to be listened to when a specific item on the navigation bar is clicked?
I would appreciate help from any person.

Thanks very much.

@cbaez440
Copy link

cbaez440 commented May 21, 2017

Hello mugabi,

BottomNavigation bottomNavigation = (BottomNavigation) view.findViewById(R.id.bottom_navigation);
bottomNavigation.setOnMenuItemClickListener(new BottomNavigation.OnMenuItemSelectionListener() {
            @Override
            public void onMenuItemSelect(@IdRes int i, int i1, boolean b) {
                // Do something, the variable i1 is the item's position clicked
            }

            @Override
            public void onMenuItemReselect(@IdRes int i, int i1, boolean b) {
                // Do something
            }
        });

I hope this clarify you.

@mugabi0978
Copy link
Author

Hello ;

Fragment selectedfragment = null;
                selectedfragment = BlankFragment.newInstance();
                FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
                //fragmentTransaction.replace(R.id.ViewPager01, blankFragment);

                fragmentTransaction.replace(R.id.ViewPager01, selectedfragment);
                fragmentTransaction.commit();

I tried the code above but the fragment doesnt display anything:-
Could you please direct me on how to display it correctly;-

Thanks.

@theshid
Copy link

theshid commented Jan 24, 2019

Hello mugabi,

BottomNavigation bottomNavigation = (BottomNavigation) view.findViewById(R.id.bottom_navigation);
bottomNavigation.setOnMenuItemClickListener(new BottomNavigation.OnMenuItemSelectionListener() {
            @Override
            public void onMenuItemSelect(@IdRes int i, int i1, boolean b) {
                // Do something, the variable i1 is the item's position clicked
            }

            @Override
            public void onMenuItemReselect(@IdRes int i, int i1, boolean b) {
                // Do something
            }
        });

I hope this clarify you.

I think it would be better for everyone using your library to document it , especially on how to use the MenuItemSelect method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants