Is it possible to append a value to R.string or any resource under R.?

by David » Sat, 24 Oct 2009 10:01:51 GMT

Sponsored Links
 Screen A permits the user to input a value into an EditText field.
Screen B populates a TextView using one of the entries in strings.xml
based upon the TextView value.  For example, if the user inputs "2" on
Screen A then Screen B should populate the TextView with
R.strings.h2.  I have tried the following:

     // get the bundle extras from Screen A's intent
     Bundle extras = getIntent().getExtras();
     // pull out the value from the UserInput EditText sent from
Screen A
     Str desiredString = extras != null ? extras.getString
("UserInput") : "";
     // popluate textView with the string R.string.h + whatever the
user put on Screen A
     textView.setText(R.string.h + desiredString);

I get a "cannot resolve R.string.h resource" error message because,
evidently, the desiredString value is not appended onto R.string.h.
So, I decided to come at it from another angle:

     switch (desiredString) {
     case 1:
     case 2:
     . . .
     case 312:

Note that you cannot switch on a string so I tried Integer.parseInt on
the string but I wind up with a blank Screen B with the switch
statement above.  It seems that the string is not turned into an int.
So, my question is twofold: (1) is it possible to append a variable
onto a R. entry and (2) if I am obliged to use the larger and uglier
switch approach, how do I turn an EditText string value into an Int
value?  Thanks.


Other Threads

1. Windows driver for HTC G1 phone

I got hold of a G1 and I could find a suitable driver. Do guys know of
any driver for Windows?
Any suggestions appreciated.



2. save data to sd card

hey can anyone develop a program in which we can save all data to our
sd card an erase them. like the internet an sms messages. it would
cause less problems if those data store there because we will be able
to do more if things same to sd card rather then on the phone itself
an the phone would run way better then lagging all the time.


3. Problems installing on a Dev Phone

4. Using instrumented h/w OpenGL ES library

5. About give new ISurface for video rendering(Both Camera and Player)

6. Contact groups

7. adb devices command sees multiple offline devices attached - but it's the same device