0

我尝试使用以下代码段从原始图像的 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;

}
4

1 回答 1

-1
getThumbnail(ContentResolver, long, int, BitmapFactory.Options) 
            (ContentResolver, Uri, int, BitmapFactory.Options)

看到不同?您为第二个参数传递了错误的类型。

于 2013-05-21T15:45:51.370 回答