我有图像视图的问题,我将一个占位符图像使用sqllite图像数据,但如何在活动中放置数据?
public class CustomCursorAdapter extends CursorAdapter {
private LayoutInflater layoutInflater;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public CustomCursorAdapter(Context context, Cursor c, int flags) {
super(context, c, flags);
layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
View v = layoutInflater.inflate(R.layout.row_data, viewGroup, false);
MyHolder holder = new MyHolder();
holder.ListID = (TextView)v.findViewById(R.id.listID);
holder.ListNama = (TextView)v.findViewById(R.id.listNama);
holder.ListNomor = (TextView)v.findViewById(R.id.listNomor);
holder.ListFoto = (ImageView)v.findViewById(R.id.listFoto);
v.setTag(holder);
return v;
}
绑定视图
@Override
public void bindView(View view, Context context, Cursor cursor) {
MyHolder holder = (MyHolder)view.getTag();
holder.ListID.setText(cursor.getString(cursor.getColumnIndex(DBHelper.row_id)));
holder.ListNama.setText(cursor.getString(cursor.getColumnIndex(DBHelper.row_nama)));
holder.ListNomor.setText(cursor.getString(cursor.getColumnIndex(DBHelper.row_nomor)));
Glide.with(holder.ListFoto.getContext())
.load(cursor.getBlob(cursor.getColumnIndex(DBHelper.row_foto)))
.into(holder.ListFoto);
}
类别myholder
class MyHolder{
TextView ListID;
TextView ListNama;
TextView ListNomor;
ImageView ListFoto;
}
谢谢你抽出时间
暂无答案!
目前还没有任何答案,快来回答吧!