Android, Baseadapter optimization when dealing with large data volumes

Source: Internet
Author: User

Android optimization is the most common is the ListView, Gallery, GridView, Viewpager Big Data optimization picture optimized access network optimization
Optimization principle: Data delay loading local cache in batches
Data optimization 1). Multiplexing Contentview
2). Create a static class Viewholder
3). batch load Slide monitor or button to show more data drag down to display

picture optimization  1). Asynchronous Load   
        2). Local cache (level two cache   memory (soft reference implementation), SD card)   
                3). Do not show pictures when sliding fast
                4). Divided into the core thread pool and the normal thread pool, download pictures and other time-consuming tasks placed in the normal thread pool

Asynchronous loading Asyntask Android packaged asynchronous data acquisition, including three methods
Doinbackground executing async methods in a child thread
Onprogressupdate the method that is executed after data acquisition, where the UI interface can be updated in the main thread
OnPostExecute methods that are executed in the main thread before the asynchronous method can be performed with friendly hints
You can also encapsulate a task class (a child thread) thread pool it needs to maintain a task list and prioritize tasks.

Code optimized for adapter:

 Public classHolderadapter<e>extendsAbstractadapter<e> {         PublicHolderadapter (Layoutinflater inflater, viewcreator<e>creator) {        Super(Inflater, creator); }        Private Static classviewholder{ Publicview view; } @Override PublicView GetView (intposition, View Convertview, ViewGroup parent) {        //Holder view mode implementation        if(Convertview = =NULL) {Viewholder holder=NewViewholder (); Convertview=Mcreator.createview (Minflater, Position,getitem (position)); Holder.view=Convertview;        Convertview.settag (holder); } Else{Viewholder Holder=(Viewholder) Convertview.gettag (); //release the data for the current viewMcreator.releaseview (Convertview, GetItem (position)); //update new data to HodlerviewMcreator.updateview (Holder.view, Position, GetItem (position)); }        returnConvertview; }}

Android, Baseadapter optimization when dealing with large data volumes

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.