CustomVideoListViewAdapter VideolistAdapter = new CustomVideoListViewAdapter(this,R.layout.video_list, songs);
audiolistview.setAdapter(VideolistAdapter);
audiolistview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
music_column_index = musicCursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
cursorPoristion = i;
musicCursor.moveToPosition(i);
String filename = musicCursor.getString(music_column_index);
mediaController.setAnchorView(videoView);
mediaController.setMediaPlayer(videoView);
mediaController.setEnabled(true);
videoView.setVideoPath(filename);
videoView.setMediaController(mediaController);
videoView.start();
videoView.setZOrderOnTop(true);
}
});
//custom adapter is here
public class CustomVideoListViewAdapter extends ArrayAdapter<AudioModel> {
Context vcontext;
public CustomVideoListViewAdapter(Context context, int resourceId,
List<AudioModel> items) {
super(context, resourceId, items);
this.vcontext= context;
}
private class VideoViewHolder {
ImageView imageView;
TextView txtTitle;
TextView txtDesc;
}
public View getView(int position, View convertView, ViewGroup parent) {
CustomVideoListViewAdapter.VideoViewHolder holder = null;
AudioModel rowItem = getItem(position);
String path=rowItem.getaPath();
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(path,
MediaStore.Images.Thumbnails.MINI_KIND);
LayoutInflater mInflater = (LayoutInflater) vcontext
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.video_list, null);
holder = new CustomVideoListViewAdapter.VideoViewHolder();
holder.txtTitle = (TextView) convertView.findViewById(R.id.video_file_nameView);
holder.imageView = (ImageView) convertView.findViewById(R.id.videothumbnail_view);
convertView.setTag(holder);
} else
holder = (CustomVideoListViewAdapter.VideoViewHolder) convertView.getTag();
holder.txtTitle.setText(rowItem.getaName());
holder.imageView.setImageBitmap(thumb);
return convertView;
}
}
运行此应用程序代码时,我无法获取视频文件列表的缩略图,但视频未显示但声音正在播放。
我已经设置了两个不同的自定义适配器来显示视频列表和音频列表...我在这里遇到的问题是视频列表未按预期从视频列表布局中显示...
< / LI> 醇>