Özel bir imleç bağdaştırıcısına sahibim ve bir görüntüyü bir ListView'de bir ImageView içine koymak istiyorum.Kaynak görüntüyü özel imleç bağdaştırıcısına getirme
Benim kodudur:
public class CustomImageListAdapter extends CursorAdapter {
private LayoutInflater inflater;
public CustomImageListAdapter(Context context, Cursor cursor) {
super(context, cursor);
inflater = LayoutInflater.from(context);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
// get the ImageView Resource
ImageView fieldImage = (ImageView) view.findViewById(R.id.fieldImage);
// set the image for the ImageView
flagImage.setImageResource(R.drawable.imageName);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return inflater.inflate(R.layout.row_images, parent, false);
}
}
Bunların hepsi tamam ama veritabanı (imleç) den resmin adını almak istiyorum. Ben
String mDrawableName = "myImageName";
int resID = getResources().getIdentifier(mDrawableName , "drawable", getPackageName());
ile çalıştı Ama hata döndürür:
İmleç'ten almak istiyorsanız, neden bunun yerine 'cursor.getString' çağırmıyorsunuz? Ve senin görüntün nerede saklanıyor? –