View ViewGroup 关于setTag 和getTag的应用 findViewWithTag

来源:互联网 发布:编程项目 编辑:程序博客网 时间:2024/04/25 14:11

主要是记录下ui 自定义时  需要用到的 View ViewGroup

常用的函数 

public void setTag(final Object tag)

public void setTag(int key, final Object tag) {

这里的int 要是一个资源id


对应的

public Object getTag(int key)
public Object getTag()
主要想记录的是View的一个函数  可以根据内容,遍历子view找到对应的view。这个函数在根据内容定位子view 刷新的时候有用
View v = layout.findViewWithTag(element);
/** * Look for a child view with the given tag.  If this view has the given * tag, return this view. * * @param tag The tag to search for, using "tag.equals(getTag())". * @return The View that has the given tag in the hierarchy or null */public final View findViewWithTag(Object tag) {







0 0
原创粉丝点击