Creating an image array with images from the assets folder? - android

[
Most of the searches I've done show solutions for creating an array with images in the drawable folder, I want to use the assets folder but I haven't been able to create an array successfully. I'm sure I'm just make a small mistake, but I'm completely stuck. Could anyone point me in the right direction?
Thanks in advance.

Not sure if this is what you're looking for, but an easy way to do it would be
List<Bitmap> mBitmapArray = new ArrayList<>();
mBitmapArray.add(gameScreen.getGame().getAssetManager().getBitmap(Asteroid1));
mBitmapArray.add(gameScreen.getGame().getAssetManager().getBitmap(Asteroid2));
mBitmapArray.add(gameScreen.getGame().getAssetManager().getBitmap(Asteroid3));
This would be creating a list as opposed to an array, but I figured that part was irrelevant. Obviously you could do the same idea with an Array.

Related

How to categorize images in the drawable folder?

I have a lot of images and I want to classify them in the drawable folder in Android Studio for easy access, is it possible?
Not possible. The only way to sort your drawable resources is by renaming them, usually with prefixes (i.e. ic_ for icons).
You can't put them in folders. However, you can control the name of them to find them easier. For example, if I have buttons coded with shapes, etc, I will name these button_name. This way, it all of my buttons are there for me to view. If I have a few minutes in a certain activity, I will do something like results_, and then all of my results images are there. Hopefully they makes sense and helps.

How to Create and Add Stickers and Smiley's In You Own Application

I have made an Android IM Application, and I'm trying to add some stickers and smileys to it, but after lots of searching, seems there is no training about it and where to Start.
I imagine it's a pain or PNG that is added to the TextView right? Can someone please put me in the right way? Even if I just know What "type" are they (png, paint, canvas, etc...), I could make my own way.
Maybe make java add an image view with the image in your drawable folder. Don't know how this would work but try somthing.

Confused about drawables and bitmaps (Android)

I am a beginner developer and I am a little confused about drawables and bitmaps. From my current understanding:
-Bitmaps are like empty images (without a type yet?)
-Drawables are images that I can draw on them
What I want to do in the first place is to open a red image I made and then draw on it. How can I do that?
Also, all drawables must be placed in the 3 drawable folders, right?
By the way, what's the different of "assets" and "res" folder?
Thank you in advance.
A drawable might be a bitmap, but maybe a shape
drawable is more general
assets holds file data
res holds (xml) defined data
Just some answers to your bunch of questions

How to swap images dynamically - wrong image showing

I need to change the source of an ImageView dynamically. I have a whole bunch of them with the same names, stored in their different dpi directories (drawable-hdpi etc) under res/. For this I've been using ImageView's setImageResource() and passing it a value from an array of resource IDs I've created at runtime like so:
decorations = new int[]{
R.drawable.bird1,
R.drawable.flower2,
R.drawable.bird3,
..etc};
Anyway, for some reason, the 6th image gets corrupted into an alternative image used for other things, not one in the resources list.
What on earth is going on?
Turns out I had a corrupt/incorrect image or the image was in the wrong directory or something. Still, strange that it decided to just display the next image in the directory rather than just crashing with an Exception or something.

Adding images into array of an Android Application

I want to display the images in my Application added to my "raw" folder of the Eclipse as it gets started.
How do I add those particular images to an Array and rotate the loop until all the Images are displayed?
Can anyone help me for this?
Check out Android's frame animation. I think it does exactly what you want.
http://developer.android.com/guide/topics/graphics/2d-graphics.html#frame-animation

Categories

Resources