Open wkns37 opened 4 years ago
We also have the same issue here.
In Android 8+ everything works fine, but in Android <8 it looks like the onLongClick()
method is not called even if isLongClickable
is true
.
(0 until count).forEach { index ->
Log.d("★", "indexe=" + index)
val menu = menuView?.getChildAt(index) as? BottomNavigationItemView ?: return@forEach
Log.d("★", "menu.itemData.title=" + menu.itemData.title)
if (menu.itemData.title == getString(R.string.account)) {
menu.setIconTintList(null)
Log.d("★", "isLongClickable=" + menu.isLongClickable)
menu.setOnLongClickListener {
Log.d("★", "aaa")
log
2021-03-04 14:20:22.399 20344-20344/★: indexe=0
2021-03-04 14:20:22.399 20344-20344/★: menu.itemData.title=チャット
2021-03-04 14:20:22.399 20344-20344/★: indexe=1
2021-03-04 14:20:22.399 20344-20344/★: menu.itemData.title=タスク
2021-03-04 14:20:22.399 20344-20344/★: indexe=2
2021-03-04 14:20:22.399 20344-20344/★: menu.itemData.title=コンタクト
2021-03-04 14:20:22.399 20344-20344/★: indexe=3
2021-03-04 14:20:22.399 20344-20344/★: menu.itemData.title=アカウント
2021-03-04 14:20:22.399 20344-20344/★: isLongClickable=true
@wkns37 @JeromeCHA Were you folks able to figure this out? I am facing the same issue where setOnLongClickListener on bottom bar is not triggering in any case. I just get isLongClickable's value false whenever I initialize the bottom bar.
@dishankmehta Nah, it's been a while since the issue. I have switched to embedded C programming and ain't interested in Android development anymore.
AFAIK, modern Jetpack Compose library has the ability to set both onClick
and onLongClick
listeners, but I'm not sure the library is ready to be in production.
I want to handle long click on BottomNavigationView items for making own context menu like its in Instagram when user can hold "accout" icon and choose another profile. I use this code:
But it works only when I start the app and holding item. If I start clicking on items and after that try to hold item again it does not work. It seems like listener stops working after user starts communicating with BottomNavigationView. Thank you.