[Android] Set onClickListener on every iteration of getView

Geoffrey Métais git at videolan.org
Wed Dec 10 10:59:08 CET 2014


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Dec 10 10:52:30 2014 +0100| [05fcd9b42f07d9d951143dffbab5fd76ead6d49b] | committer: Geoffrey Métais

Set onClickListener on every iteration of getView

It avoids the listener to be reused on other items.
popup context menu was loaded for the wrong items.

This should fix delete for wrong files.

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=05fcd9b42f07d9d951143dffbab5fd76ead6d49b
---

 .../org/videolan/vlc/gui/video/VideoListAdapter.java    |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index c2515c9..08a4258 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -154,13 +154,6 @@ public class VideoListAdapter extends ArrayAdapter<Media>
             holder.listmode = mListMode;
             v.setTag(holder);
 
-            holder.more.setOnClickListener(new OnClickListener() {
-                @Override
-                public void onClick(View v) {
-                    if (mFragment != null)
-                    mFragment.onContextPopupMenu(v, position);
-                }
-            });
 
             /* Set the layoutParams based on the values set in the video_grid_item.xml root element */
             v.setLayoutParams(new GridView.LayoutParams(v.getLayoutParams().width, v.getLayoutParams().height));
@@ -168,6 +161,14 @@ public class VideoListAdapter extends ArrayAdapter<Media>
             holder = (ViewHolder) v.getTag();
         }
 
+        holder.more.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (mFragment != null)
+                    mFragment.onContextPopupMenu(v, position);
+            }
+        });
+
         Media media = getItem(position);
 
         /* Thumbnail */



More information about the Android mailing list