您的位置:首页 > 其它

View ViewGroup 关于setTag 和getTag的应用 findViewWithTag

2015-11-27 19:08 513 查看
主要是记录下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) {

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  findViewWithTag