android - images in gridview from lazyloading are mixing places on scroll -


In my application, I'm loading lazy in a gridview with the URL. When I scroll through my grid view, the images change their position. How is this possible ? I'm new to Android so can anybody help?

This is my list adapter code:

  import android.app.activity; Import android.content.Context; Import android.view.LayoutInflater; Import android.view.View; Import android.view.View.OnClickListener; Import android.view.ViewGroup; Import android.widget.BaseAdapter; Import android.widget.ImageView; Public class LazyImageLoadAdapter BaseAdapter applies OnClickListener {Personal Activity Activity; Private string [] mStrings; Private reference mContext; Private stationary layoutInflator inflater = faucet; Public ImageLoader imageLoader; Public LazyImageLoadAdapter (Reference Reference, Activity A, String [] D) {Activity = A; MStrings = d; MContext = Reference; Inflater = (Layout Inflator) Activity getSystemService (Context.LAYOUT_INFLATER_SERVICE); ImageLoader = new imager (activity.getApplicationContext ()); } Public int getCount () {return mStrings.length; } Public object getItem (status of int) {return status; } Public ITMID in the long run (status of return) {Return Status; } View public viewView (int position, seeviewview, viewgroup parents) {see grid; Inflater = (layout infographic) mContext.getSystemService (Reference. LEOUT_INFLATER_SERVICE); If (convertView == empty) {grid = new View (mContext); Grid = inflater.inflate (R.layout.listview_row, tap); ImageView imageView = (ImageView) grid.findViewById (R.id.image); ImageLoader.DisplayImage (mStrings [status], imageView); } And {grid = (see) convertview; } Grid.setOnClickListener (new OnItemClickListener (status)); Return grid; } @ Override Public Zero (see Arg 0) {} Private class OnItemClickListener applies OnClickListener {Private int mPosition; OnItemClickListener (status of int) {mPosition = status; } @ Override Public Zero (see Arg 0) {MainActivityLoading sct = (MainActivityLoading) Activity; Sct.onItemClick (MPOSITION); }}   

thanks

This should work: see public getView (integer status, seeviewview, viewgroup parent) {inflater = (LayoutInflater) mContext.getSystemService (reference. LEOUT_INFLATER_SERVICE); If (convertView == faucet) {convertView = inflater.inflate (R.layout.listview_row, empty); } ImageView imageView = (ImageView) Convert View.findViewById (R.id.image); ImageLoader.DisplayImage (mStrings [status], imageView); // Use GridViewSetOnTamClickListCan ConvertWhite.SetOnClicklist (NewOne ItemClicklist (Status)); Return Convertview; }

The point here is that once you get a null-empty convertView you need to set the value.

Because of the url of ImageView in the block:

  imageLoader.DisplayImage (mStrings [position], imageView);   

If convertView is not zero if you start recycling the GridView views, you can see the old convertView Which is outside the screen and whose image URL is different .

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -