I have an array of files contained in the sdcard: i would like to show an item in a ImageSwitcher but could not find the SetImageBitmap but only SetImageResource, but i have not these in res folder.
How can i do it?
use this below code instead of setImageBitmap. I think you have files in array.
imgSwitcher.setImageURI(Uri.fromFile(filename));
Related
I'm trying to access my background colours and images for onBindViewHolder method.
Images are in res.mipmap folder after I created new Image assets.
Colours are in res.values.colours.xml file
Thanks in advance for help.
for exact code see image:
https://i.stack.imgur.com/h7Gq4.jpg
if you want to access resources, you can use view's context.
holder.view.resources.getColor(id)
holder.view.resources.getDrawable(id)
I want to store images for my quizz app on android with ArrayList.The images must be stored in the folder drawable.
Is someone can explain me how to do this?
Thank you
Pate your Images in the drawable folder and access them from your activity using R.drawable.imagenames.
Paste the images in your drawable folder.
Create a ArrayList in your code and add all the images to the arraylist
ArrayList<View> imageList = new ArrayList<>();
imageList.add(image1);
imageList.add(image2);
...and so on
How can I populate the image switcher dynamically, when I have the images in the drawable folder and sub folder .. like drawable-ldpi/S_001/a001_001.jpg.
I have tried to populate one image, but the application crashed.
Here is the code:
ImageSwitcher imageSwitcher = (ImageSwitcher) findViewById(R.id.imageSwitcher);
imageSwitcher.setImageDrawable(getResources().getDrawable(getResources().getIdentifier("S_001/a001_001.jpg", "drawable", getPackageName())));
I need some assisstance.
drawables folder is for img resources used by your app, like icons, 9-patches, backgrounds and other ui elements. You can't put subdirectories there.
If you plan to use some photos in an ImageSwitcher or anything like this, you should use assets folder. Read this to find out more.
GalleryView instead of getting from drawable is it possible to get from asset folder all images?if it is possible?explain how?i tried by set and getbitmap..if i use that what should i need to return in getcount method?
How to pick image from particular folder, say sdcard/mypics?
i can recommend the gridview tutorial.
you will have to modify the code a bit to get the resource into an array before showing the gridview. but therefore you can use the BitmapFactory class.