XML 中 setTag(key, value) 的等价性 [英] Equivalence of setTag(key, value) in XML
本文介绍了XML 中 setTag(key, value) 的等价性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在我的 Android 布局文件中使用 setTag(key)
的等效项:
I can use equivalence of setTag(key)
at my Android layout files as this:
<EditText android:id="@+id/passwordEdit"
android:tag="key"
android:inputType="textPassword"/>
我想在我的 xml 中使用 setTag(key, value)
的等效项.
I would like to use equivalence of setTag(key, value)
at my xml.
有可能吗?
推荐答案
我参加聚会有点晚了...但无论如何,如果您使用 api 级别 21 或更高级别,您可以从 xml 执行此操作.我不确定内存泄漏问题是否仍然存在.
I'm a bit late to the party... but anyways you can do this from xml if you are using api level 21 or above. I am not sure whether the memory leak issue is still present or not.
<Button
android:layout_width=match_parent
android:layout_height=wrap_content
android:text="New button" >
<tag android:id="SomeId" android:value="SomeValue" />
</Button>
这篇关于XML 中 setTag(key, value) 的等价性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文