Note that there are some explanatory texts on larger screens.

plurals
  1. POImages change position on scrolling in Android
    text
    copied!<p>In my android application, I am fetching the images from the url and displaying it in Grid View. But when I scroll down, the images change the position randomly. I am using Async thread to fetch the image and update the Image View object. Any suggestions how to solve this ...</p> <p>I have refered to the question <a href="https://stackoverflow.com/questions/15598287/images-in-gridview-change-their-position-on-scrolling-in-android">Images in gridview change their position on scrolling in android</a> but it didin't help me</p> <hr> <pre><code>My code for getView and loading the image @Override public View getView(final int position, View convertView, ViewGroup parent) { final HashMap&lt;String, String&gt; song = songsList.get(position); imageURL = song.get(VariablesList.TAG_ALBUM_IMAGE); View v = null; if (convertView != null) v = convertView; else v = inflater.inflate(R.layout.gridlayout_item, parent, false); final ImageView imageView = (ImageView) v.findViewById(R.id.icon_image); new LoadImage().execute(imageURL,imageView); imageView.setOnClickListener(new View.OnClickListener() { // @Override public void onClick(View v) { albumUrl = new StringBuffer(resources.getString(R.string.songsListURL)); String albumIndex = song.get("id"); albumName = (song.get("name")); imageURL = song.get(VariablesList.TAG_ALBUM_IMAGE); SongsList albumList = new SongsList(imageURL, albumUrl, albumName,albumIndex,resources); Thread threadAlbumList = new Thread(albumList); threadAlbumList.start(); synchronized (albumList) { try { albumList.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } if (!NewMediaPlayer.mediaPlayer.isPlaying()) { HashMap&lt;String, String&gt; playingSong = NewMediaPlayer.selectedSongs .get(0); if (playingSong != null) { String url = playingSong.get("songUrl"); String songName = playingSong.get("songName"); if (songName != null) { NewMediaPlayer.songTitleLabel.setText(albumName + " - " + songName); NewMediaPlayer.songTitle.setText(albumName+"-"+songName); } NewMediaPlayer.playSong(url); } } } }); TextView itemAlbumName = (TextView) v.findViewById(R.id.icon_text); itemAlbumName.setText(song.get("name")); itemAlbumName.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { HashMap&lt;String, String&gt; song = songsList.get(position); String songIndex = song.get("id"); String albumName = (song.get("name")); Intent in = new Intent(context, SongListActivity.class); in.putExtra("albumIndex", songIndex); in.putExtra("albumName", albumName); in.putExtra("AlbumImage", song.get(VariablesList.TAG_ALBUM_IMAGE)); context.startActivity(in); } }); return v; } public void LoadImage extends AsyncTask&lt;Object, Void, Bitmap&gt;{ ImageView imageView; @Override protected BitMap doInBackground(Object... urls) { String imageURL = (String)urls[0]; imageView = (ImageView)urls[0]; BitMap image = AlbumList.LoadImagetoGridView(imageURL) return image } @Override protected void onPostExecute(BitMap result) { imageView.setImageBitmap(result); } } </code></pre>
 

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