A tag is a property of a view, or it can be said that a map used by view to store parameters. It is useful for improving performance and parameter passing, such as improving the performance of a listview:
View for cache items
ItemViewHolder holder;
if (convertView == null) {
holder = new ItemViewHolder();
convertView = (context).inflate(.view_item, null);
= (TextView) (.text_item_content_time);
= (TextView) (.text_item_content_remark);
(holder);
} else {
holder = (ItemViewHolder)();
}
if(((position).getGroupId()).isShown()){
(.child_show, true);
}else{
(.child_show, false);
}
return convertView;
}
Tags are used in the above code. If it is one, just setTag directly. What if there are multiple ones?
setTag also has an overload with int type, but setting a constant of final type or writing dead numbers will appear:
The key must be an application-specific resource id exception:
You need to define an ID in the file and then set it here! !
The above is the full content of the wonderful use of Android development setTag. I hope it can give you a reference and I hope you can support me more.