I have a custom cursor adapter, and I would like to put an image in an ImageView in a ListView.
My code is:
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) {
This is all fine, but I would like to get the image name from the database (cursor). I tried using
String mDrawableName = "myImageName"; int resID = getResources().getIdentifier(mDrawableName , "drawable", getPackageName());
But the error returned is: "The getResources () method is undefined for the type CustomImageListAdapter"
source share