Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid image loading in listview
    primarykey
    data
    text
    <p>In my Android application an Asyntask is used for loading images from web in a list view.I want to show the center portion of the image and I have tried imageloader for loading images but the problem is image clarity is very poor but I have used it for loading thumbnails because thumbnail is very small.So that I have tried an Asyntask which is given below.The problem with this method is image view shows other images that means image view in first list item will show the next list item's image and after some time it will display the correct image.How can I solve this issue.Or suggest a method for lading images with good clarity.Please help me.Thanks in advance</p> <pre><code>private class DownloadImageTask extends AsyncTask&lt;String, Void, Bitmap&gt; { ImageView bmImage; ProgressBar mProgressBar; String url; public DownloadImageTask(ImageView bmImage, ProgressBar progressBar) { this.bmImage = bmImage; this.mProgressBar = progressBar; } @Override protected void onPreExecute() { mProgressBar.setVisibility(View.VISIBLE); super.onPreExecute(); } protected Bitmap doInBackground(String... urls) { String urldisplay = urls[0]; url = urldisplay; Bitmap mIcon11 = null; try { InputStream in = new java.net.URL(urldisplay).openStream(); mIcon11 = BitmapFactory.decodeStream(in); } catch (Exception e) { // Log.e("Error", e.getMessage()); e.printStackTrace(); } return mIcon11; } protected void onPostExecute(Bitmap result) { Utilities.addBitmapToMemoryCache(url, result); bmImage.setImageBitmap(result); mProgressBar.setVisibility(View.GONE); // result.recycle(); } } </code></pre> <p>}</p> <pre><code>public View getView(final int position, View convertView, ViewGroup parent) { vi = convertView; int type = getItemViewType(position); // Utilities.message_player = new MediaPlayer(); if (vi == null) { inflater = LayoutInflater.from(mcontext); if (type == ITEM_TYPE_ONE) vi = inflater.inflate(R.layout.message_group_list_item, null); else vi = inflater.inflate(R.layout.listlastrow, null); } if (type == ITEM_TYPE_ONE) { if (fontType == true) { } ((ImageView) vi.findViewById(R.id.imageMessage)).setTag(position+"i"); Bitmap bmp = Utilities.getBitmapFromMemCache(feedsImage); if(bmp == null){ DownloadImageTask dwnloadImgTask = new DownloadImageTask(((ImageView) vi.findViewWithTag(position+"i")), ((ProgressBar) vi.findViewById(R.id.progressBar1))); dwnloadImgTask.execute(feedsImage); }else{ ((ImageView) vi.findViewById(R.id.imageMessage)).setImageBitmap(bmp); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload