如何设置由code一个片段标记? [英] How to set a Fragment tag by code?

查看:125
本文介绍了如何设置由code一个片段标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还没有发现在片段类像 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.

这篇关于如何设置由code一个片段标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆