Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable BottomNavigationView click and Touch?

i want to implement behavior on certain condition the bottom view is unable to click, i want to make if bottom view item being click it does not navigate to that item but still stay at the current item

this is my bottom view layout

like image 480
Muhammad Aiman Bin Kamal Avatar asked Oct 03 '17 08:10

Muhammad Aiman Bin Kamal


People also ask

How do I disable BottomNavigationView?

Dynamicaly using Java pr Kotlin you can disable click. bottomView. setOnClickListener(null); try this.

What is BottomNavigationView in android?

com.google.android.material.bottomnavigation.BottomNavigationView. Represents a standard bottom navigation bar for application. It is an implementation of material design bottom navigation. Bottom navigation bars make it easy for users to explore and switch between top-level views in a single tap.

How to implement bottom navigation in android studio?

To create a Menu Resource File , click on the app -> res -> menu(right-click) -> New -> Menu Resource File and name it bottom_nav_menu. Now the user can create as many items as he wants in the bottom_nav_menu. xml file. The user also needs to create an icon for each of these items.


2 Answers

Kotlin style one-liner:

bottom_navigation.menu.forEach { it.isEnabled = false }
like image 189
Sai Avatar answered Oct 17 '22 14:10

Sai


You can disable menu items if you want to disable bottom navigation view

private void enableBottomBar(boolean enable){
    for (int i = 0; i < mBottomMenu.getMenu().size(); i++) {
        mBottomMenu.getMenu().getItem(i).setEnabled(enable);
    }
}
like image 34
ysfcyln Avatar answered Oct 17 '22 14:10

ysfcyln