How to get a text from resources (string.xml)
-
I have a code.
Pattern p = Pattern.compile(R.string.regexDate + R.string.regexTime + R.string.regexLast);
Method
Pattern.compile(String string)
requires a string parameter, but fromstring.xml
I get it.int
♪ So, I'm getting the interns from theR.java
but I need straight lines. ♪ ♪Resources from string.xml
<string name="regexDate" >^[2][\\d]{3}[0-1]{1}[\\d]{1}[0-3]{1}[\\d][_]</string> <string name="regexTime">[0-2][\\d]([0-5][\\d]){2}[_]</string> <string name="regexLast">[0]{3}[b][\\.][d][b]$</string>
Read the documentation. ♪ ♪
One optionrow:
String s = getString(R.string.regexDate);
Second option:
Resources res = getResources(); res.getString(R.string.regexDate)
I can't use these options as methods.
getString(...), getResources()
Eclipse can't see.How do I get it?
string.xml
straight away, not her.id
? If it's an example.
-
Methods
getResources()
orgetString()
fromContext
becausecontext
has access to programme resources.You can't get the line.
string.xml
♪As a colt, you can write
enum
♪ but don't do it or use it ♪public static final string
in the class that Pattern uses