android:带缩略图的列表视图

时间:2011-03-01 11:14:25

标签: android image android-listview

我需要创建带有缩略图的视频列表视图。图像名称来自数据库。我可以为textview赋值,但是当尝试为图像视图赋值时,它也会在位图中崩溃

        class CustomSimpleCusorAdapter extends SimpleCursorAdapter{
    private Context context;
    private int layout;
    //TextView title;
    public CustomSimpleCusorAdapter(Context context, int layout, Cursor c,
            String[] from, int[] to) {

        super(context, layout, c, from, to);
        // TODO Auto-generated constructor stub
        this.layout=layout;
        this.context =context;

    }

public View newView(Context context, Cursor cursor, ViewGroup parent) {

     LayoutInflater inflater = LayoutInflater.from(context);
      View view = inflater.inflate(layout, parent, false);

     return view;
    }
@Override
public void bindView(View v, Context context, Cursor c) {

    Log.d("DATABAT",c.getString(c.getColumnIndexOrThrow(NotesDbAdapter.VIDEO_TITLE)));
    Log.d("DATABAT",c.getString(c.getColumnIndexOrThrow(NotesDbAdapter.VIDEO_IMAGE)));

    TextView section_text = (TextView) v.findViewById(R.id.title);
    section_text.setText(c.getString(c.getColumnIndexOrThrow(NotesDbAdapter.VIDEO_TITLE)));
    ImageView thumb =(ImageView)findViewById(R.id.icon);
  //         
    String filename = "flag_1";
      int id = context.getResources().getIdentifier(filename, "drawable", context.getString(R.string.package_str));
  Log.d("ID",""+id);

  thumb.setBackgroundResource(R.drawable.menuicon);

}

} 

由于

2 个答案:

答案 0 :(得分:1)

试试

 String urldisplay=img_value.toString();
 InputStream in = new java.net.URL(urldisplay).openStream();
 mIcon11 = BitmapFactory.decodeStream(new PatchInputStream(in));
 mIcon11=ImageHelper.getRoundedCornerBitmap(mIcon11,30);
 holder.icon.setImageBitmap(mIcon11);

答案 1 :(得分:1)

好的......在这里轻轻踩踏,但这听起来就像我的好友在试图为他的视频应用程序显示缩略图时所遇到的问题......

这是Encode/Decode tutorial for base64

仅供参考;这是他在市场上的应用程序的链接(300,000+下载):Video Player