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 - How do I use a string resource for a string variable?

How do I use a string resource for a string variable?

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

How do I use a string resource for a string variable?

Postby SlumberMachine » Tue Oct 13, 2009 1:08 am

so my string is R.string.menu_exit in the strings xml file. I can call these correctly for stuff like:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. this.getWindow().setTitle(Resources.getText(R.string.main_title));
  2.  
  3.  
Parsed in 0.013 seconds, using GeSHi 1.0.8.4


and
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. msgTextView.setText(R.string.hello_message);
Parsed in 0.010 seconds, using GeSHi 1.0.8.4


But how do I set my own local string variable to the resource:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private String myString = R.string.menu_exit;
Parsed in 0.010 seconds, using GeSHi 1.0.8.4


This obviously does not work, what is the correct way?
SlumberMachine
Developer
Developer
 
Posts: 39
Joined: Tue Feb 24, 2009 9:00 pm

Top

Postby padde » Tue Oct 13, 2009 1:50 am

If you are in a class which extends activity you can use

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. private String myString = getResources().getString(R.string.menu_exit);
  3.  
  4.  
Parsed in 0.010 seconds, using GeSHi 1.0.8.4
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby SlumberMachine » Tue Oct 13, 2009 9:44 am

Thank you VERY much! That was exactly what I was looking for. Yes, it is in a "extended activity". Perfect! You made my day! :D
SlumberMachine
Developer
Developer
 
Posts: 39
Joined: Tue Feb 24, 2009 9:00 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 10 guests