BottomNavigationView 设置为不可点击

BottomNavigationView set to non-clickable

我的主视图中有一个 BottomNavigationView activity,我已经尝试了所有方法来使按钮(项目)不可点击。

在 BottomNavigationView 的 main_menu 中,我有:

  android:clickable="false"
  android:contextClickable="false"

在每个项目中......

在 java 我有:

    bottomNavigationView.setEnabled(false);
    bottomNavigationView.setFocusable(false);
    bottomNavigationView.setFocusableInTouchMode(false);
    bottomNavigationView.setClickable(false);
    bottomNavigationView.setContextClickable(false);
    bottomNavigationView.setOnClickListener(null);

项目仍然可以点击......

不是我的答案,但应该有效

setCheckable(false) for first item

navigation.getMenu().getItem(0).setCheckable(false);

item.setCheckable(true) inside onNavigationItemSelected()

public boolean onNavigationItemSelected(MenuItem item) {

switch (item.getItemId()) {
    case R.id.navigation_home:
        item.setCheckable(true);
        mTextMessage.setText(R.string.title_home);
        return true;
}
return false;
}