setTag(key)
我可以在我的 Android 布局文件中使用等价,如下所示:
<EditText android:id="@+id/passwordEdit"
android:tag="key"
android:inputType="textPassword"/>
我想setTag(key, value)
在我的 xml 中使用等价的。
是否可以?
我参加聚会有点晚了......但无论如何,如果您使用 api 级别 21 或更高级别,您可以从 xml 执行此操作。我不确定内存泄漏问题是否仍然存在。
<Button
android:layout_width=match_parent
android:layout_height=wrap_content
android:text="New button" >
<tag android:id="SomeId" android:value="SomeValue" />
</Button>
有这个:
<tag android:id="..." android:value="..."/>