Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Beginner Question: access R.string dynamically

Beginner Question: access R.string dynamically

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

Beginner Question: access R.string dynamically

Postby boredom2 » Sat Dec 26, 2009 12:18 am

Hi,

I'coming from the AS3/PHP World and am not that familiar with JAVA, thats why I think have to ask a simple question:

when accessing constants from R, e.g. getString(R.string.app_name), I need to access them dynamically, like:

String varname='app_name';
getString(R.string.varname)

where varname is the variable, in AS3, it would be R.string[varname], but that does not work with Java.
I know of the Reflection API, but this is not available in android, isnt it?

I am sure, that this is possible.
Anybody can help me, please?

thank you,
Christoph
Germany
boredom2
Freshman
Freshman
 
Posts: 2
Joined: Sat Dec 26, 2009 12:13 am

Top

Postby sing1e » Sun Dec 27, 2009 2:47 pm

Hi.
Java is a static language,but as3 is a dynamic language. So, java is not allowed to access attribute like as3.

But, in java, you can use reflection instead of some dynamic method~(My English is not good enough~)

In the loading procedure, you can load all you image in a hashmap, the key of the hashmap is the name of you image. Then, your program can access image by name in the runtime!
sing1e
Freshman
Freshman
 
Posts: 9
Joined: Sat Dec 12, 2009 10:55 am

Postby boredom2 » Sun Dec 27, 2009 5:59 pm

Thank you,

exactly that is, what I implemented yesterday. The times, I worked with java, are ages ago... :lol:

Thank you!
christoph
boredom2
Freshman
Freshman
 
Posts: 2
Joined: Sat Dec 26, 2009 12:13 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 7 guests