我在缩略图中显示视频时遇到问题..
从数据库中检索视频链接并将其存储在字符串数组中。
我想在缩略图网格视图中显示视频数组。如何实施?它可以显示吗?
谁能帮我?提前非常感谢。
我试过这个......
vid = new ArrayList<String>(new ArrayList<String>(vid));
runOnUiThread(new Runnable() {
public void run() {
setContentView(R.layout.gallery);
GridView grd = (GridView)findViewById(R.id.gridView1);
grd.setAdapter(new ImageAdapter(this));
grd.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent,View v,int pos,long id)
{
Toast.makeText(getBaseContext(),
"pic"+(pos+1)+"select ",Toast.LENGTH_SHORT).show();
}
});
}
});
return;
private class ImageAdapter extends BaseAdapter {
private final Runnable context;
public ImageAdapter(Runnable runnable) {
context = runnable;
}
public int getCount()
{
return vid.size();
}
public Object getItem(int position)
{
return position;
}
public long getItemId(int position)
{
return position;
}
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);
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;
}