gpt4 book ai didi

android - 导航组件中使用的标签属性是什么?

转载 作者:行者123 更新时间:2023-11-29 18:30:49 25 4
gpt4 key购买 nike

根据docs :

The Label field contains the name of the destination’s XML layout file.

很公平,但我似乎无法找到它的用途。为什么布局文件需要命名?

<fragment
android:id="@+id/blank"
android:name="com.example.app.BlankFragment"
android:label="Blank"
tools:layout="@layout/fragment_blank"/>

label 属性是否严格用于导航框架的内部工作,而不是我应该担心的事情?

最佳答案

根据 Update UI components with NavigationUI documentation :

NavigationUI contains methods that automatically update content in your top app bar as users navigate through your app. For example, NavigationUI uses the destination labels from your navigation graph to keep the title of the top app bar up-to-date.

When using NavigationUI with the top app bar methods discussed below, the label you attach to destinations can be automatically populated from the arguments provided to the destination by using the format of {argName} in your label.

就像附加到每个目的地的任何其他信息一样,它也可以用在 custom OnDestinationChangedListener 中。如果您有其他 UI 需要使用当前目的地的标签进行更新。

关于android - 导航组件中使用的标签属性是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56387346/

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