gpt4 book ai didi

java - BottomNavigationView 设置为不可点击

转载 作者:行者123 更新时间:2023-12-02 11:45:04 26 4
gpt4 key购买 nike

我的主要 Activity 中有一个 BottomNavigationView,并且我已经尝试了一切方法来尝试使按钮(项目)不可点击。

在 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;
}

关于java - BottomNavigationView 设置为不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48274210/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com