Material-BottomNavigation
Material-BottomNavigation copied to clipboard
How to implement onitemclick listener?
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.
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.
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.
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