Home > Mobile >  Android link server information display on the ListView click jump details and figure images can be
Android link server information display on the ListView click jump details and figure images can be

Time:12-03

//use an asynchronous task load images, also is a kind of implementation of child thread
The class LoadImageTask extends AsyncTask {
Controls to display images//statement
Private ImageView ImageView.
LoadImageTask (ImageView ImageView) {
Enclosing imageView=imageView;
}
//are commonly used to perform background tasks for the UI done before 1 tag
@ Override
Protected void onPreExecute () {
Super. OnPreExecute ();
}
@ Override
Protected Bitmap doInBackground (String... Strings) {
Bitmap Bitmap=null;
The URL//picture
String bmUrl=strings [0];
Try {
Bitmap=BitmapFactory. DecodeStream (new URL (bmUrl). OpenStream ());
} the catch (IOException e) {
e.printStackTrace();
}
Return the bitmap;
}
//when the background at the end of the operation, this method is called, the results will be passed as a parameter to this method, the result is shown in the UI directly component
@ Override
Protected void onPostExecute (Bitmap Bitmap) {
If (bitmap!=null) {
ImageView. SetImageBitmap (bitmap);
}
Super. OnPostExecute (bitmap);
}}

CodePudding user response:

You use Glide or directly ImageLoader framework
  • Related