1
我需要創建視頻的列表視圖與它的縮略圖images.The圖像名稱來自數據庫。我可以給textview的價值,但當試圖給圖像視圖價值它也崩潰位圖android:縮略圖列表視圖
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);
}
}
感謝