Its very simple, instead of string array use object arraylist which has thumbnail/bitmap for the grid item and video url like given below.
class video
{
Bitmap thumnail;
String videoURL;
}
From database make an arraylist of this video class then use that arraylist in getview.
videoList = new ArrayList<Video>();
// populate videolist
public int getCount()
{
return videoList.size();
}
public View getView(int position, View convertView, ViewGroup parent)
{
ImageView picturesView;
if (convertView == null) {
picturesView = new ImageView((Context) context);
//Creation of Thumbnail of video
//Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(vid.get(position),0);
Bitmap bitmap = videoList.get(position).thumnail;
picturesView.setImageBitmap(bitmap);
picturesView.setScaleType(ImageView.ScaleType.FIT_XY);
//picturesView.setPadding(8, 8, 8, 8);
picturesView.setLayoutParams(new Gallery.LayoutParams(150, 120));
}else {
picturesView = (ImageView)convertView;
}
return picturesView;
}
Then in the onitemclick, using the same arraylist you can get the videourl and you can play the video in separate screen.
grd.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent,View v,int pos,long id)
{
String videoLink = videoList.get(pos).videoURL;
// pass this video link to another activity where you want to play the video
}
});