gpt4 book ai didi

android - 带有 BottomBar 的 Android 应用程序上的无限循环

转载 作者:行者123 更新时间:2023-11-30 01:16:42 25 4
gpt4 key购买 nike

我想在我的 android 应用程序上使用新的底部导航模式。

我找到了图书馆BottomBar来自 Github 上的 roughike。我的应用程序应该有四个选项卡,每个选项卡都应该代表一个 Activity 。因此,我实现了一个应该处理点击的“BaseActivity”。

库有两个回调

  1. onMenuTabSelected
  2. onMenuTabReSelected

代码:

 @Override
public void onMenuTabSelected(@IdRes int menuItemId) {
Intent intent = null;
switch (menuItemId) {
case R.id.menu_overview:
intent = new Intent(this, OverviewActivity.class);
break;
case R.id.menu_transactions:
intent = new Intent(this, TagsActivity.class);
break;
case R.id.menu_tags:
intent = new Intent(this, TagsActivity.class);
break;
}

if (intent != null) {
startActivity(intent);
}
}

每次应用程序启动时,都会调用 onTabSelected 方法并执行第一种情况。这将产生一个无限循环。每次都会调用我的第一个选项卡...

有人知道我该如何处理这个问题吗?

最佳答案

如果在为底部栏 (mBottomBar.setItems(R.menu.bottombar)) 设置项目后设置 OnMenuTabClickListener,则会发生此循环。

只要改变顺序,就不会出现循环。

关于android - 带有 BottomBar 的 Android 应用程序上的无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37764057/

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