我尝试使用以下代码段从原始图像的 URI 中获取缩略图。
Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(
context.getContentResolver(), uri,
MediaStore.Images.Thumbnails.MINI_KIND,
(BitmapFactory.Options) null );
我的 URI uri
:
Uri uri = Uri.parse(ki.getEreignisbild());
现在,该getThumbnail
功能带有红色下划线,并且错误消息显示
The method getThumbnail(ContentResolver, long, int, BitmapFactory.Options)
in the type MediaStore.Images.Thumbnails is not applicable for the arguments
(ContentResolver, Uri, int, BitmapFactory.Options)
谷歌搜索但没有找到任何东西。有什么想法我能做什么?
编辑:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolderEreignis holder;
if(convertView == null){
convertView = inflator.inflate(R.layout.list_ereignis, parent, false);
holder = new ViewHolderEreignis((TextView) convertView.findViewById(R.id.enullline), (TextView) convertView.findViewById(R.id.efirstLine), (ImageView) convertView.findViewById(R.id.eimgv));
convertView.setTag(holder);
}
else{
holder = (ViewHolderEreignis) convertView.getTag();
}
Ereignis ki = (Ereignis) getItem(position);
holder.getEreignisname().setText(ki.getEreignisname());
holder.getEreignisdatum().setText(ki.getEreignisZeit());
Uri uri = Uri.parse(ki.getEreignisbild());
String imageUri;
try{
String path = ki.getEreignisbild();
Bitmap de = resizeBitmap(path);
Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(
context.getContentResolver(), uri,
MediaStore.Images.Thumbnails.MINI_KIND,
(BitmapFactory.Options) null );
// Drawable drawable = holder.getEreignisbild().setImageDrawable(R.drawable.male);
// holder.getEreignisbild().setImageResource(R.drawable.male);
}
catch(Exception e){
}
return convertView;
}