android - Display video stored in SD card in a GridView -


i want display videos stored inside sd card in gridview. have followed this tutorial , changed suit need. below code getview() inside customadapter class

public view getview(int position, view convertview, viewgroup parent) {         view listitemrow;         listitemrow = layoutinflater.from(vcontext).inflate(r.layout.sd_card_list_item, parent, false);          textview txttitle = (textview)listitemrow.findviewbyid(r.id.txttitle);         imageview thumbimage = (imageview)listitemrow.findviewbyid(r.id.videocapture);         videocolumnindex = videocursor.getcolumnindexorthrow(mediastore.video.media.display_name);         videocursor.movetoposition(position);         txttitle.settext(videocursor.getstring(videocolumnindex));         videocolumnindex = videocursor.getcolumnindexorthrow(mediastore.video.media.size);         videocursor.movetoposition(position);         int videoid = videocursor.getint(videocursor.getcolumnindexorthrow(mediastore.video.media._id));         cursor videothumbnailcursor = getcontentresolver().query(mediastore.video.thumbnails.external_content_uri,                 thumbcolumns, mediastore.video.thumbnails.video_id+ "=" + videoid, null, null);          if (videothumbnailcursor.movetofirst())         {             thumbpath = videothumbnailcursor.getstring(videothumbnailcursor.getcolumnindex(mediastore.video.thumbnails.data));         }         thumbimage.setimageuri(uri.parse(thumbpath));         thumbimage.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 toast.maketext(videostoredinsdcardactivity.this,"video clicked",toast.length_short).show();                 intent intent=new intent(videostoredinsdcardactivity.this,samplevideoactivity.class);                 startactivity(intent);              }         });          return listitemrow;  } 

the issue facing getting same thumbnail image(1st video thumbnail) video.

what wrong in above code?

also, how can path of video file user clicked inside onclicklistener?

thanks in advance!

you getting path first position videothumbnailcursor.movetofirst()

you need maintain position in getview method according position


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -