I'm looking for a way to convert a string to a charsequence.
My code is:
The random int r is created outside the method. This method gives a random string, from my resource file. All of the strings have names q1,q2,q3,... There will be 100+ such strings.
This doesnt work at all. the setText(cs) line fails. Is there any way to convert string -> charsequence? Or to have it read as a resource file and not a string?
My code is:
Code:
public void randText(int r){
r++; //necessary increment
String rs = Integer.toString(r); //random string
String qs ="R.string.q"+rs;//question string.
CharSequence cs = qs.subSequence(0, 12);
newtv.setText(cs); //this is a textview.
The random int r is created outside the method. This method gives a random string, from my resource file. All of the strings have names q1,q2,q3,... There will be 100+ such strings.
This doesnt work at all. the setText(cs) line fails. Is there any way to convert string -> charsequence? Or to have it read as a resource file and not a string?