Made a small case to get the picture from the network and load it into Viewpager just started using asynchttpclient for data download and encapsulated a method inside a class class is the use of async I want to get the result of Async's network request by the return value of the method of this class of encapsulation. How can the results of network requests not get the result of the Web request and then the debugging process found that the network request is actually requested, but in the return of the method is not returned, so only to reflect the reason of the thread I checked the back again. Async's Onsuccess method is that the main thread handles only a certain understanding of the threads and has no coding experience so it abandons async
And then study the use of volley, just started to use for the loop load Imagerequest to fetch the network picture one of the package into the map and then the map into a list and then the list returned to the same as async real new, so I studied again
Finally, use Imageloader and use LRUCache to cache the picture.
for (int i=0;i<urls.length;i++) {
ImageView image = New ImageView (getactivity ());
Image.setscaletype (ImageView.ScaleType.FIT_XY);
Image.setonclicklistener (New Myclick (i));
Imageloader Imageloader = new Imageloader (Requestqueue,bitmapcache);
Imagelistener listener = Imageloader.getimagelistener (image, R.drawable.icon_default, r.drawable.image10);
Imageloader.get (Urls[i], listener);
Views.add (image);
}
Asynchronous download for Android (Asynchttpclient and Volley)