Android Development--Settag's magical and the key must be application-specific resource ID exception _android

Source: Internet
Author: User

tag is an attribute of view, or a map that holds the parameters, which is useful for improving performance and parameter passing, such as improving ListView performance:

View that is used to cache item

Copy Code code as follows:
Public View GetView (final int position, View Convertview, ViewGroup parent) {
Itemviewholder Holder;

if (Convertview = = null) {
Holder = new Itemviewholder ();
Convertview = Layoutinflater.from (context). Inflate (R.layout.view_item, NULL);
Holder.timetextview = (TextView) Convertview.findviewbyid (r.id.text_item_content_time);
Holder.remarktextview = (TextView) Convertview.findviewbyid (R.id.text_item_content_remark);
Convertview.settag (holder);
} else {
Holder = (itemviewholder) convertview.gettag ();
}
if (Mmessagelistgroup.get mmessagelist.get (position). Getgroupid ()). Isshown ()) {
Convertview.settag (R.id.child_show, true);
}else{
Convertview.settag (R.id.child_show, false);
}

return convertview;
}

In the above code used to the tag, if it is a say directly settag can, if there are more than how to do?

Settag also has an overload with an int type, but setting a final type constant or writing a dead number appears:

The key must is an APPLICATION-SPECIFIC resource ID exception :

You need to define an ID in the Ids.xml file and set it here!!

The above is Android development Settag all the content of the magical, hope to give you a reference, but also hope that we support cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.