【发布时间】:2014-10-21 06:43:18
【问题描述】:
public void setTag(final Object tag) {
mTag = tag;
}
public Object getTag() {
return mTag;
}
这是 Android 中 View 类的两个方法。 以下分别是这两种方法的官方文档。
/**
* Returns this view's tag.
*
* @return the Object stored in this view as a tag
*
* @see #setTag(Object)
* @see #getTag(int)
*/
/**
* Sets the tag associated with this view. A tag can be used to mark
* a view in its hierarchy and does not have to be unique within the
* hierarchy. Tags can also be used to store data within a view without
* resorting to another data structure.
*
* @param tag an Object to tag the view with
*
* @see #getTag()
* @see #setTag(int, Object)
*/
标签函数在 baseadapter 实现中被广泛使用,但我无法理解它的用途以及如何使用它们。请你解释一下这个很好的例子来帮助我理解这些函数的作用
【问题讨论】:
标签: android android-view