- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 BottomNavigationView
带有导航组件。当显示 fragment 不是根 fragment 时,选项卡图标不会更新(选中)。
例子:
当我在带有 fragment A(它是根 fragment )的 Tab Home 和带有 fragment B(也是根 fragment )的 Tab Star 之间切换时,它工作正常。
但是,当我从 Tab Home 导航到另一个 fragment (如 fragment A2)并点击 Tab Star 并再次返回 Tab Home 时,仍然在 BottomNavigationView
中选择了 Tab Star .
它在版本 2.4.0-alpha05
上运行良好, 当我将其更新为 2.5.0-alpha01
时发生这种情况.
build.gradle(应用程序)
implementation "androidx.navigation:navigation-fragment-ktx:2.5.0-alpha01"
implementation "androidx.navigation:navigation-ui-ktx:2.5.0-alpha01"
implementation "androidx.navigation:navigation-dynamic-features-fragment:2.5.0-alpha01"
build.gradle(根)
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0-alpha01"
图形:
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/graph"
app:startDestination="@id/fragmentA">
<fragment
android:id="@+id/fragmentA"
android:name="ui.test.FragmentA"
tools:layout="@layout/fragment_test"
android:label="FragmentA" >
<action
android:id="@+id/action_fragmentA_to_fragmentA2"
app:destination="@id/fragmentA2" />
</fragment>
<fragment
android:id="@+id/fragmentA2"
android:name="ui.test.FragmentA2"
tools:layout="@layout/fragment_test"
android:label="FragmentA2" />
<fragment
android:id="@+id/fragmentB"
android:name="ui.test.FragmentB"
tools:layout="@layout/fragment_test"
android:label="FragmentB" />
</navigation>
菜单:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/fragmentA"
android:icon="@drawable/ic_home"
android:title="" />
<item
android:id="@+id/fragmentB"
android:icon="@drawable/ic_star"
android:title="" />
</menu>
难道我做错了什么?或者这是错误?
最佳答案
所以对我有用的是 ianhanniballake 在他的回答中暗示的解决方案:使用 setOnItemSelectedListener。
// always show selected Bottom Navigation item as selected (return true)
bottomNavigationView.setOnItemSelectedListener { item ->
// In order to get the expected behavior, you have to call default Navigation method manually
NavigationUI.onNavDestinationSelected(item, navController)
return@setOnItemSelectedListener true
}
这将始终选择项目并导航到关联的目的地,同时保持多个后退堆栈。
关于Android导航组件: BottomNavigationView's selected tab icon is not updated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71089052/
我正在开发一个 Android 项目,其中有一个抽屉导航,其中显示了 GroupSection 对象的列表。所有 GroupSection 对象都包含一个部分图标。抽屉图标由 TypedArray 和
$('a[class*=icon-]').append(""); 使用我现在拥有的代码,我可以转动: 进入 但我想将选定的类“icon-edit”附加到跨度类中。因为我想要这样的东西: var
我正在建立一个网站,我希望在视觉上有一排字体很棒的图标看起来具有相同的高度。这也意味着我希望他们都坐在同一基线上。 由于图标的性质是具有不同纵横比的不同形状,当您将具有相同字体大小或 fa-2x(等)
我有两个图标,其中一个图标为 .gif,另一个图标为 .png。所以我想组合这些图标,将动画图标放在另一个图标之上。 此代码适用于静态图标,但在放置动画图标时,它不会打印动画。 public clas
当我在控制台中运行 gatsby develop 时,会出现此错误: ERROR #11331 PLUGIN Invalid plugin options for "gatsby-plugin-ma
在适用于iPhone的iOS 7上,有一个新的应用程序图标大小:120x120。我使用此尺寸来创建iOS 7专用图标。在iOS 6上,它将自动采用“旧” 114x114图标,在iOS 7上,它将采用新
我的简单问题是:是否可以将图标组件内的文本居中,我尝试像 child 一样传递文本,但它不起作用?还有其他解决方案吗?我知道可能的解决方案是使用 position: 'absolute' 但还有其他方
我有这个代码: if(seatE1.getIcon() == particular icon) { // do something } 我不知道在特定图标中写什么。我应该写我想要的图标的路径还
在调用 System.Drawing.Icon.ToBitmap() 创建图像后,是否可以安全地处理原始 Icon? 最佳答案 该方法将 Icon 转换为新的 Bitmap 对象,因此不会有从 Bit
这个图钉图标的名称是什么? 最佳答案 现在 Material Icon 中提供了准确的图标。 图标名称:push_pin 图标网址:https://material.io/resources/icon
数据如下: df % ggplot(aes(label = parts, values = values)) + geom_pictogram(n_rows = 10, aes(color =
我正在为 VSCode 编写扩展。在 WebviewPanel 中,我需要显示来自文件图标主题的文件扩展名图标。是否有从文件图标主题中获取图标的功能? 最佳答案 我也在研究这个。我还没有答案,但到目前
我正在组装一个通用应用程序,并且我的项目中有图标,但是我不断从编译器收到关于Icon.png的警告。 我按照http://developer.apple.com/library/ios/#qa/qa2
我正在组装一个通用应用程序,并且我的项目中有图标,但是我不断从编译器收到有关Icon.png的警告。 我按照http://developer.apple.com/library/ios/#qa/qa2
我下载了“Office 2010 Add-In: Icons Gallery ”,这是一个 docx 文件,其中有两个包含图标的后台选项卡。 如何提取图标或在我的应用程序中使用它们? 最佳答案 我在
我正在开发一个 MacOS 应用程序,该应用程序应显示应用程序图标。对于某些应用程序,它可以工作,对于某些应用程序,它不能。 Notes.app 是我没有获得应用程序图标图像的应用程序。 let ic
我只是在Android Studio中创建了一个模板项目,我没有更改一行代码(DrawerLayout模板项目)。 但是,我发现用于显示导航 fragment 的单击图标始终是向左箭头,即使在代码中它
我正在尝试找出如何使用 xpath 通配符来获取网站图标: $doc = new DOMDocument(); $doc->strictErrorChecking = FALSE; $doc->loa
Mobile Safari对于比传统 16x16 分辨率更高的图标,需要使用以下咒语: 但是,Firefox 需要使用 HTML5 syntax ,例如: 现在,我的期望是可以将它们组合成一行
我目前为动态创建的 QPushButton 使用以下样式表属性 string mystyle = "QPushButton { border: 1px solid #8f8f91; border-
我是一名优秀的程序员,十分优秀!