Two different data types are inserted in a ListView list of Android, androidlistview

Source: Internet
Author: User

Two different data types are inserted in a ListView list of Android, androidlistview
Two different data codes are inserted in a ListView list of http://www.cnblogs.com/roucheng/ Android:

Public class ViewHolder {Button fenzu_btn_1; Button fenzu_btn_2; Button fenzu_btn_3;} public class ViewHolder1 {TextView tvTitle; TextView tvLetter;}/*** when the ListView data changes, call this method to update ListView * @ param listhttp: // www.cnblogs.com/roucheng/p/csslogin.html */public void updateListView (List <SortModel> list) {this. list = list; policydatasetchanged ();} public int getCount () {return this. list. size ();} public Object getItem (int position) {return list. get (position) ;}@ Override public int getItemViewType (int position) {// TODO Auto-generated method stub int p = position; if (p = 0) return 0; else return 1 ;}@ Override public int getViewTypeCount () {return 2 ;}public View getView (final int position, View view, ViewGroup arg2) {int type = getItemViewType (position ); if (view = null) {inflater = LayoutInflater. from (mContext); if (type = 1) {view = inflater. inflate (R. layout. item, arg2, false); viewHolder1 = new ViewHolder1 (); viewHolder1.tvTitle = (TextView) view. findViewById (R. id. title); viewHolder1.tvLetter = (TextView) view. findViewById (R. id. catalog); view. setTag (viewHolder1);} else {// http://www.cnblogs.com/roucheng/p/csslogin.html view = inflater. inflate (R. layout. items2, arg2, false); fenzu_btn_1 = (LinearLayout) view. findViewById (R. id. fenzu_btn_1); view. setTag (viewHolder) ;}} else {switch (type) {case 1: viewHolder1 = (ViewHolder1) view. getTag (); break; case 0: viewHolder = (ViewHolder) view. getTag (); break;} return view ;}

More effect: http://www.cnblogs.com/roucheng/p/texiao.html

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.