public void setTag(final Object tag) {
mTag = tag;
}
public Object getTag() {
return mTag;
}
這些是Android中View Class的兩種方法。 以下是這兩種方法的官方文檔。Android:View類中的getTag()和setTag()的用途
/**
* 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實現,但我無法理解它的目的以及如何使用它們。你能解釋一下這個很好的例子來幫助我理解這些功能的作用嗎?
可能重複(HTTP://計算器。 COM /問題/ 5291726 /什麼 - 是最主要目的 - 的 - settag-gettag的方法的視圖) – rds 2015-06-22 11:52:11