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