Display effect:
The middle item entry is able to swipe up and down.
Code implementation:
1 @Override2 PublicView GetView (intposition, View Convertview, ViewGroup parent) {3 4 Viewholder Holder;5 if(Convertview = =NULL) {6Convertview = View.inflate (cleancacheactivity. This,7R.layout.list_item_cacheinfo,NULL);8Holder =NewViewholder ();9 TenHolder.tvname =(TextView) Convertview One . Findviewbyid (r.id.tv_name); AHolder.tvcache =(TextView) Convertview - . Findviewbyid (R.id.tv_cache); -Holder.ivicon =(ImageView) Convertview the . Findviewbyid (R.id.iv_icon); -Holder.ivclean =(ImageView) Convertview - . Findviewbyid (R.id.iv_clean); - + Convertview.settag (holder); -}Else { +Holder =(Viewholder) Convertview.gettag (); A } at FinalCacheinfo info =GetItem (position); - Holder.tvName.setText (info.name); -Holder.ivIcon.setImageDrawable (Info.icon);
26//...
Convertview return;
28}
1 //ListView Property Encapsulation2 classViewholder {3 PublicTextView Tvname;4 PublicTextView Tvcache;5 PublicImageView Ivicon;6 PublicImageView Ivclean;7 }8 9 //Cache Information EncapsulationTen classCacheinfo { One PublicString name; A PublicString PackageName; - Publicdrawable icon; - Public LongcacheSize; the}
Optimization Features:
1.
Reduce the number of Findviewbyid
2.
Reduce the number of objects created (Holder = new viewholder ();)
3.
achieve paging load, save consumption.
ListView Display in Android and its optimization benefits