how to put the R.drawables.* into an array

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

how to put the R.drawables.* into an array

Postby reynolds » Fri Mar 06, 2009 8:20 am

I'd like know which method can I use that will return all images/files that is in the R.drawables. The reason I asked coz, I want to avoid creating a fixed array, coz later I will have to add images again at R.drawables, dynamically.

Thanks,
reynolds
Junior Developer
Junior Developer
 
Posts: 22
Joined: Fri Mar 06, 2009 6:13 am
Location: Makati Philippines

Top

Postby MrSnowflake » Fri Mar 06, 2009 11:08 am

Use reflection, so you can run through the values of R.drawable.

The implementation is your assignment for today, due next week :).
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby reynolds » Sat Mar 07, 2009 8:20 am

MrSnowflake wrote:Use reflection, so you can run through the values of R.drawable.

The implementation is your assignment for today, due next week :).


Thanks, I'll try it as soon as possible.

Btw, I'm very new to Android, and I'm originally a C/C++/PHP programmer. It took me a day to understand Java!

So please bear with me. Thanks ^_^
reynolds
Junior Developer
Junior Developer
 
Posts: 22
Joined: Fri Mar 06, 2009 6:13 am
Location: Makati Philippines

Postby reynolds » Mon Mar 09, 2009 3:32 am

argh... I'm still new to Java, as I can' understand the logic of how to use Reflection. Does anybody have an example function /method?

Thanks,
reynolds
Junior Developer
Junior Developer
 
Posts: 22
Joined: Fri Mar 06, 2009 6:13 am
Location: Makati Philippines

Postby MrSnowflake » Mon Mar 09, 2009 12:17 pm

The java tutorial explain everything pretty good.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot] and 5 guests