Adding badges to Bottom navigation and not able to reference the getOrCreateBadge(正在向底部导航添加徽章,并且无法引用getOrCreateBadge)
本文介绍了正在向底部导航添加徽章,并且无法引用getOrCreateBadge的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正尝试在底部导航中添加徽章,但问题是getOrCreateBadge没有被引用。我无法访问此方法。
错误:未解析的引用:getOrCreateBadge
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bnv_nav"
app:defaultNavHost="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bnv_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/dp56"
android:layout_alignParentBottom="true"
android:fitsSystemWindows="true"
app:itemIconTint="@drawable/tab_color"
app:itemTextColor="@drawable/tab_color" />
主题
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/white</item>
<item name="android:textViewStyle">@style/AppTheme.Widget.TextView</item>
<item name="android:actionBarStyle">@style/AppTheme.ActionBar</item>
<item name="android:navigationBarColor" tools:targetApi="21">@color/white</item>
<item name="android:windowLightNavigationBar" tools:targetApi="27">true</item>
<item name="android:windowDisablePreview">true</item>
</style>
我正在运行时添加菜单项。
我已经尝试的内容:
- 从XML本身添加菜单项:仍然没有效果
- 改主题为材料主题:仍然是同一期
- 使用底部导航活动创建了一个单独的项目:如果我添加徽章,该项目中没有问题。我也把它的主题改成了我的应用程序主题,也就是说,App compat仍然可以在该项目中使用徽章。
- 最初Android素材没有添加依赖项,我可以使用底部导航栏。但由于我在添加徽章时遇到了问题,所以我在外部添加了依赖性,并确保将最新版本也放在最后,但仍然面临同样的问题。无法在底部导航中添加徽章。
我知道这是很基本的东西,但如果有人能指出这一点,那将是一个很大的帮助,因为这个问题已经在过去两天里被困住了。提前感谢。
推荐答案
理想情况下,应该使用实现‘com.google.android.Material:Material:1.3.0’。确保在Gradle同步和重建之前删除了Builds文件夹。
这篇关于正在向底部导航添加徽章,并且无法引用getOrCreateBadge的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
织梦狗教程
本文标题为:正在向底部导航添加徽章,并且无法引用getOrCreateBadge


基础教程推荐
猜你喜欢
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01