android:list view with thumbnail

余生长醉 提交于 2019-12-24 05:50:59

问题


I need to create the list view of video's with it thumbnail images.The image name come from the database.I can give value to textview but when try to give value to image view it crash also in bitmap

        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);

}

} 

Thanks


回答1:


Okay ... treading lightly here, but this sounds exactly like the problem my buddy had when trying to display the thumbnails for his videos app ...

Here's an Encode/Decode tutorial for base64

And just for reference; here's the link to his app in the market (300,000+ downloads): Video Player




回答2:


Try this where

 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);


来源:https://stackoverflow.com/questions/5153727/androidlist-view-with-thumbnail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!