getThumbnail方法不适用于该类型

时间:2013-05-21 15:38:37

标签: android image thumbnails

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

}

1 个答案:

答案 0 :(得分:-1)

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

看到区别?你为第二个参数传递了错误的类型。