android - Keep the correct value item in a listview using AsyncTask -


I am a beginner using Android and I have a problem when I try to display a list of images together I am facing an event with a button for each image when displaying the URL of the image when pressing the button. So, when I scroll on the screen, different URL in the new images appear when you press their buttons are the first pictures of the same match these values ​​to be displayed before the scroll on the screen

My main address this Type is:.

  Public class ImagenesAdapter extends BaseAdapter {Private context mContext; Private map & lt; String ,? & Gt; MListImagenes; Static class viewer {public button buttonholder; Public ImageView imageviewHolder; Int position; } Public Imagination Adapter (Reference C, Map & lt; String,? & Gt; list) {mContext = c; MListImagenes = List; } @ Override Public Interest () {Return MList Imagensis (); } @OverWide Public Objects Found Itam (Int Position) {Return MList Imagines.Jet (Status); } @ Override Public Long ITMID (Status of Intake) {Return Status; } @ Override public view getView (int position, seeviewview, ViewGroup parent) {// refer to the reference to convert v = see convertview; ViewHolder viewholder = null; Final difference posicion = position; // if the new layout blends if tap (V == empty) {layout inflator = inflatile = layoutInfletture.fr (MCTX); V = inflater.inflate (R. layout.activism_lissado_mijen_subidas, empty); // View Config Holder Holder = New Viewholder (); ViewHolder.buttonHolder = (button) v.findViewById (R.id.btnCopiarImagenUrl); ViewHolder.imageviewHolder = (ImageView) v.findViewById (RID.image); viewHolder.buttonHolder.setOnClickListener (New OnClickListener () {@Override public void onClick (View v) {CopiarImagenListado (Posicion); Toast.makeText (mContext, "Imagen copiada", Toast.LENGTH_SHORT) .show ();}}); V.setTag (viewHolder); } Else {viewHolder = (seeholder) v.getTag (); } Shared reference prefsTH = mContext.getSharedPreferences ( "PrefsTH", ListadoImagenesSubidasMain.MODE_PRIVATE); String cadnya URL = ""; String SP = prefsTH.getString ("urlTH" + status, ""); If (sp! = "") {CadenaURL = sp; If ((viewholder.imewviewholder! = Null) & amp; amp; (Cadana URL! = "")) {ViewHolder.position = Status; New DownloadAsyncTask (seeholder, status). Execute (Cadana URL); }} Return V; } Private class DownloadAsyncTask asyncTask & lt extending string, zero, string & gt; {Private ProgressDialog dialog = New ProgressDialog (mContext); Private viewer mHolder; Private intimation; Public DownloadAsyncTask (seeholder holder, int status) {this.mHolder = holder; This.mposition = Status; } PreExecute at protected void () {dialog.setMessage ("Cargando imágenes ..."); Dialog.show (); } @ Override protected string doInBackground (string ... parameter) {string URL = param [0]; Return url; } PostXtech (string result) on protected void {if (showing dialog.is ()) {dialog.dismiss (); } If (result! = Null & amp; mposition == mHolder.position) {mHolder.buttonHolder.setText ("Copier"); Picasso With (mContext) .load (results). Inn (mHolder.imageviewHolder); }} Private Zero CopiarImagenListado (int position) {SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences (mContext); Prefs = PreferenceManager.getDefaultSharedPreferences (mContext); String cadnya URL = ""; String SP = prefs.getString ("url" + status, ""); If (sp! = "") {CadenaURL = sp; Clipboard manager clipboard = (clipboard manager) mContext.getSystemService (mContext.CLIPBOARD_SERVICE); Clip data clip = clip data. Newplayline Text ("Imagine Coparda", SP); Clipboard.setPrimaryClip (clip); }}   

What do I have to do to display new pictures in the list view when I do not lose new data?

Thanks in advance.

"itemprop =" text ">

could your try this:

  // increase the new layout If zero if (v = = null) {layout inflection = layout inflator.fr (mctxt); V = inflater.inflate (R. layout.activism_lissado_mijen_subidas, empty); // View Config Holder Holder = New Viewholder (); ViewHolder.buttonHolder = (button) v.findViewById (R.id.btnCopiarImagenUrl); ViewHolder.imageviewHolder = (ImageView) v.findViewById (RID.image); V.setTag (viewHolder); } Else {viewHolder = (seeholder) v.getTag (); } ViewHolder.buttonHolder.setOnClickListener (New OnClickListener () {@Override public void onClick (View v) {CopiarImagenListado (Posicion); Toast.makeText (mContext, "Imagen copiada", Toast.LENGTH_SHORT) .show ();}}) ;   

Even if visual recycled, you onClick Posicion includes has been done.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -