Android Maozhuaweibo Adapter ListView optimization and sending micro-blog-4

Source: Internet
Author: User

This article is mainly for you to talk about adapter ListView optimization and send Weibo, we all know that Android in some of the more memory-intensive classes, in order to avoid wasting inside

We need to optimize our components and so on, so that they save unnecessary waste of resources


Custom adapters:

Package com.neweriweibo.adapter;/** * Adapter * @author engineer-jsp * @date 2014.10.28 * */import java.util.arraylist;import Com.neweriweibo.r;import Com.neweriweibo.model.userweibiinfo;import Com.squareup.picasso.picasso;import Android.content.context;import Android.util.log;import Android.view.layoutinflater;import Android.view.View; Import Android.view.viewgroup;import Android.widget.baseadapter;import Android.widget.imageview;import Android.widget.textview;public class Messageadapter extends Baseadapter {private Context mcontext;p rivate arraylist&lt ; userweibiinfo> mresult;p rivate layoutinflater layoutinflater;public messageadapter (context context, ArrayList< userweibiinfo> result) {Mcontext = context; mresult = result; Layoutinflater = Layoutinflater.from (Mcontext);} @Overridepublic int GetCount () {return mresult.size ();} @Overridepublic Object getItem (int position) {return mresult.get (position);} @Overridepublic long Getitemid (int position) {return position;} @Overridepublic VIew GetView (int position, View Convertview, ViewGroup parent) {Viewholder holder; View view = Convertview, if (view = = null) {holder = new Viewholder (); view = Layoutinflater.inflate (r.layout.message_list_ item, NULL); holder.tvname = (TextView) View.findviewbyid (r.id.m_tv_username); holder.tvmessage = (TextView) View.findviewbyid (r.id.m_tv_message); holder.headimg = (ImageView) View.findviewbyid (R.id.weibo_item_icon); View.settag (holder); }else{holder = (Viewholder) View.gettag ();} LOG.D ("Weibo friend message-username test:", mresult.get (position). GetName ()); Holder.tvName.setText (Mresult.get (position). GetName ()); LOG.D ("Weibo friend message-content test:", mresult.get (position). Getorigtext ()); Holder.tvMessage.setText (Mresult.get (position). Getorigtext ()); LOG.D ("Weibo friend message-avatar address test:", mresult.get (position). GETHEADIMG ()); Picasso.with (View.getcontext (). Getapplicationcontext ()). Load (mresult.get (position). GETHEADIMG ()). into ( HOLDER.HEADIMG); return view;} Static class Viewholder{textview Tvname; TextView tvmessage; ImageView headimg;}}

Viewholder is one of the ListView optimization methods
Send Message interface:
Currently only with text send function, expression package are in the source code has, interested, can continue to develop, the following provide source learning:
Address: <a target=_blank href= "http://download.csdn.net/detail/jspping/8117425" target= "_blank" >http:// Download.csdn.net/detail/jspping/8117425</a><strong><span style= "Font-size:14px;color: #ff0000;" ></span></strong><pre name= "code" class= "Java" >
OK, things are not many, the key is to master the method


Android Maozhuaweibo Adapter ListView optimization and sending micro-blog-4

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.