Void Android. View. View. settag (Object Tag) Public void Settag (Object Tag) Since: API Level 1
Sets the tag associated with this view. A tag can be used to mark a view in its hierarchy and does not have to be unique within the hierarchy. tags can also be used to store data within a view without resorting to another data structure.
Parameters An object to tag the view
Also see
Gettag ()
Settag (INT,
Object)
Public View getview ( Int Position, view convertview, viewgroup parent ){ Final Int Cc = Position; viewholder holder = Null ; If (Convertview = Null ) {Holder =New Viewholder (); convertview = Minflater. Inflate (R. layout. itemrow, Null ); Holder. tagcolor = (Imageview) convertview. findviewbyid (R. Id. itemrowiamge); Holder. itemname = (Textview) convertview. findviewbyid (R. Id. itemrowtext); Holder. CB = (Checkbox) convertview. findviewbyid (R. Id. itemrowcb); convertview. settag (holder );} Else {Holder =(Viewholder) convertview. gettag ();} // Obtain the data filled in viewholder. Holder. tagcolor. setbackgroundresource (integer) itemlist. Get (position). Get ("IMG" ); Holder. itemname. settext (string) itemlist. Get (position). Get ( "Itemname" ); Holder. CKD = (String) itemlist. Get (position). Get ("checked" ); // The checkbox key listening function in a single project Holder. CB. setonclicklistener ( New View. onclicklistener (){ Public Void Onclick (view v) {SETC (CC ); // Call the function to change the status after being pressed. }}); If (Holder. CKD. Equals ("T" ) Holder. CB. setchecked ( True ); Else Holder. CB. setchecked ( False ); Return Convertview ;}
Set a holder class
Import Android. widget. checkbox; Import Android. widget. imageview; Import Android. widget. textview; // The viewholder class is used to store the data required by each project. Public Class Viewholder { Public Imageview tagcolor; // Images in a single project Public Textview itemname; // Text in a single project Public Checkbox CB; // Checkbox in a single project Public String CKD; // String variable used to identify the checkbox status in a single project }
You can.