I have taken following array; to fill-up gallery:
private Integer[] mImageIds = { R.drawable.one, R.drawable.two,
R.drawable.three, R.drawable.four, R.drawable.five,
R.drawable.six, R.drawable.seven, R.drawable.eight,
R.drawable.nine, R.drawable.ten, R.drawable.elevan,
R.drawable.twelve, R.drawable.thirteen, R.drawable.fouteen,
R.drawable.fifteen, R.drawable.sixteen
};
and then I am using click event of gallery:
coverFlow.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView arg0, View v, int position,
long rowID) {
String s = mImageIds[position].toString();
Toast.makeText(v.getContext(), s , 1000).show();
}
});
but here Toast gives me integer number 2130837507;
If I take only mImageIds[position] in Toast
then it displays path res/drawable-mdpi/image_name.jpg, but actually it is not string.
And I want to retrieve String (image_name) from it.
Can any one help me?
Don’t do a toString on the number you get back. If you want a string from the resource Id as the title of your question suggests, do this:
However, it seems like you want the image name, though that’s not what the title of your question is. If that’s the case, this should work: