I have a RecyclerView
in which I am displaying an integer array of Drawable
. However I have a folder of Bitmaps on the sd card I want to display instead. But I have not been able to work out how to convert the bitmaps into drawables and put them into an int array for display or even if this is the best way of working this out.
This is this is the code for where I set my adapter in onCreateView where I use getData()
to give the images for the adapter:
adapter = new ProgressImagesListAdapter(getActivity(), getData());
mProgressImagesListRecycler.setAdapter(adapter);
This is getData():
public List<ProgressImagesListInformation> getData() {
List<ProgressImagesListInformation> mFrontViewImagesList = new ArrayList<>();
int[] mImages = new int[]{
R.drawable.boomer,
R.drawable.bosco,
R.drawable.brewster,
R.drawable.dory,
R.drawable.gabby,
R.drawable.hunter,
R.drawable.kitkat,
R.drawable.doug,
R.drawable.mae,
R.drawable.millie
};
for (int i = 0; i < mImages.length; i++)
{
ProgressImagesListInformation current = new ProgressImagesListInformation();
current.mImageId = mImages[i];
mFrontViewImagesList.add(current);
}
return mFrontViewImagesList;
}
The way I was thinking was to change the contents of getdata(), make a for loop that converts the contents of sd card folder bitmaps into array of drawables using somthing like the line below in the for loop but I have not been able to work a way to implement it. This obviously gives me the error found type bitmap expected type integer but I don't understand why or how to fix it.
ArrayList<Integer> ImagesArray = new ArrayList<>();
for (int i = 0; i < sNumberOfFilesInImageDirectory; i++)
{
ImagesArray.add(new BitmapDrawable(getResources(), MyBitmapImage));
}
Thanks for your help.