android - How to Configure Listview with more than 16 Items in GetView with holder -
i have problem getview adding items in listview baseadapter. when store "0 15 items " " if(position == 0 )
if(position == 15)
" displays listview items in sequence. when try adding 1 more (16th) item listview (like if(position == 16)
), displays first item in listview , doesn't show 16th item have added array.
i using custom listview row , each row has own function interacts users. don't know how add more 16 items in getview using 'position'.
i have listview of 21 items can not implement more 16 items.
any 1 have solution of pls tell me
getview code
public view getview(int position, view convertview, viewgroup parent) { // todo auto-generated method stub holder holder; textview tv1; imageview img; textview desc; layoutinflater inflater = context.getlayoutinflater(); if(convertview == null){ convertview = inflater.inflate(r.layout.screenlock_addapter, parent,false); holder = new holder(); if(position == 0 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 1 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.htv.settext(listitem[position]); convertview.settag(holder); } if(position == 2 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 3 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 4 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 5 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 6 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 7 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 8 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 9 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 10 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 11 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 12 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 13 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 14 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == 15 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == position + 1 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == position + 2 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == position + 3 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == position + 4 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } if(position == position + 5 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } } else { holder = (holder) convertview.gettag(); } return convertview; }
try out code...
public view getview(int position, view convertview, viewgroup parent) { // todo auto-generated method stub holder holder; textview tv1; imageview img; textview desc;
layoutinflater inflater = context.getlayoutinflater(); if(convertview == null){ convertview = inflater.inflate(r.layout.screenlock_addapter, parent,false); holder = new holder(); if(position == 1 ){ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.htv.settext(listitem[position]); convertview.settag(holder); } else{ holder.htv = (textview) convertview.findviewbyid(r.id.scl_tv); holder.himg = (imageview) convertview.findviewbyid(r.id.scl_img); holder.hdesc = (textview) convertview.findviewbyid(r.id.scl_desc); holder.htv.settext(listitem[position]); holder.hdesc.settext(desc1[position]); holder.himg.setimageresource(aimg[position]); convertview.settag(holder); } } else { holder = (holder) convertview.gettag(); } return convertview;
}
Comments
Post a Comment