如何设置由code一个片段标记?片段、标记、如何设置、code

2023-09-12 22:50:09 作者:梦一场她起弦风雅

我还没有发现在片段类像 setTag(字符串标记名)方法。设置,我发现了一个片段标签的唯一方法是做一个 FragmentTransaction ,并通过一个标记名称作为参数

I haven't found something like setTag(String tagName) method in the Fragment class. The only way to set a Fragment tag that I have found is by doing a FragmentTransaction and passing a tag name as parameter.

这是要明确地设置片段由code标记的唯一途径?

Is this the only way to explicitly set a Fragment tag by code?

推荐答案

是的。所以,唯一的办法就是在交易时间,如使用添加替换,或作为布局的一部分。

Yes. So the only way is at transaction time, e.g. using add, replace, or as part of the layout.

我决定这个通过的相容性来源的审查,因为我简要地看着类似,在过去的某个点。

I determined this through an examination of the compatibility sources as I briefly looked for similar at some point in the past.