View ViewGroup 关于setTag 和getTag的应用 findViewWithTag

主要是记录下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) {







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值