How to obtain the object of each Item in ListView in android Development

Source: Internet
Author: User

First, write a data adapter of the ListView, pull it out, and write an object to set the object of each Item of the listView. You can use ConvertView to set setTag to include the View house tag. You can use ListvIEW. getChildAt (). getTag. get the object you want, set parameters, or iron code!

 

 

GetView:

ItemObj viewHolder = null;
If (convertView = null ){
ViewHolder = new ItemObj ();
ConvertView = mLayoutInflate. inflate (R. layout. simple_item, null );
ViewHolder. mSimpleCardName = (TextView) convertView. findViewById (R. id. simple_name );
ViewHolder. mIsReTake = (TextView) convertView. findViewById (R. id. simple_num );
ViewHolder. mContentNext = (TextView) convertView. findViewById (R. id. status );
ViewHolder. mIsNext = (TextView) convertView. findViewById (R. id. icon_next );
ConvertView. setTag (viewHolder );
} Else {
ViewHolder = (ItemObj) convertView. getTag ();
}
 
PhotoList aPotoLists = (PhotoList) getItem (position );

If (aPotoLists! = Null ){
ViewHolder. mSimpleCardName. setText (aPotoLists. photoName );
If (KeyInMapITF. TAKESIMPLE_PIC_TEP! = Null ){
ViewHolder. mIsReTake. setText ("(" + 0 + ")");
If (KeyInMapITF. TAKESIMPLE_PIC_TEP.equals (aPotoLists. photoName )){
ArrayList <PhotoList> aLists = (ArrayList <PhotoList>) GlobalParameter. get (KeyInMapITF. TAKESIMPLE_PIC_TEP );
ViewHolder. mIsReTake. setText ("(" + aLists. size () + ")");
}
}

If (aPotoLists. status. equals ("0 ")){
ViewHolder. mContentNext. setText ("unreviewed ");
ViewHolder. mIsNext. setBackgroundDrawable (mContext. getResources (). getDrawable (R. drawable. task_list_arrows ));

} Else {
ViewHolder. mContentNext. setText ("reviewed ");
ViewHolder. mIsNext. setText ("");
ConvertView. setOnClickListener (null );
}
}

 

 

Obj object:

Public class ItemObj extends Object {

Public TextView mSimpleCardName; // name of the document
Public TextView mIsReTake; // 0 is a document photo; 1 is a duplicate photo
Public TextView mContentNext; // unsubmitted and unreviewed
Public TextView mIsNext; // arrow
Public TextView getmSimpleCardName (){
Return mSimpleCardName;
}
Public void setmSimpleCardName (TextView mSimpleCardName ){
This. mSimpleCardName = mSimpleCardName;
}
Public TextView getmIsReTake (){
Return mIsReTake;
}
Public void setmIsReTake (TextView mIsReTake ){
This. mIsReTake = mIsReTake;
}
Public TextView getmContentNext (){
Return mContentNext;
}
Public void setmContentNext (TextView mContentNext ){
This. mContentNext = mContentNext;
}
Public TextView getmIsNext (){
Return mIsNext;
}
Public void setmIsNext (TextView mIsNext ){
This. mIsNext = mIsNext;
}
 

 

 

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.