我创建了一个视频播放应用程序。我在其中使用列表视图显示视频,但是当我为视频添加缩略图时,在列表视图中滚动时遇到问题
谢谢!
public class Adapter extends ArrayAdapter<VideoInfo> {
private ArrayList<VideoInfo> fullsongpath;
Adapter(Context context, ArrayList<VideoInfo> fullsongpath) {
super(context, 0, fullsongpath);
this.fullsongpath = fullsongpath;
}
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
View listItemView = convertView;
if (listItemView == null) {
listItemView = LayoutInflater.from(getContext()).inflate(
R.layout.listitem, parent, false);
}
VideoInfo s = fullsongpath.get(position);
TextView sngnm1 = listItemView.findViewById(R.id.txtTitle);
TextView dura1 = listItemView.findViewById(R.id.duration1);
ImageView imgIcon = listItemView.findViewById(R.id.imgIcon);
sngnm1.setText(s.video_name);
dura1.setText(s.duration);
Bitmap bm= ThumbnailUtils.createVideoThumbnail(s.Path, MediaStore.Video.Thumbnails.MINI_KIND);
imgIcon.setImageBitmap(bm);
return listItemView;
}