0

I´m using but i have see numbers instead of string

 canvas.drawText(String.valueOf(R.string.game_lovers), 170, 150, paint);
  • Its in Surface to use the String where is in the Drawtext WTF duplicate –  Sep 02 '16 at 00:48
  • 1
    Yeah, that "sentence" doesn't really make any sense. The linked _possible_ duplicate should at least make it clear that the `R.string` value isn't the actual `String` itself. If you want more help, you need to provide more context to your issue. We're not mind readers. We don't know where the single line of code you've provided is in your project. – Mike M. Sep 02 '16 at 00:52
  • "but i have see numbers" -- Yes, because all values of `R.whatever` are actually integers. Definitely a duplicate – OneCricketeer Sep 02 '16 at 01:03

2 Answers2

0

No, you can't get string from resources like that. You should do it this way:

@NonNull String getString(@NonNull Context cotext,@StringRes int stringResId) {
    return cotext.getString(stringResId);
}

Where res would be you res id R.string.game_lovers

Kosh
  • 6,140
  • 3
  • 36
  • 67
Artur Dumchev
  • 1,252
  • 14
  • 17
0

if it draws in View class, you may try

canvas.drawText(getContext().getString(R.string.game_lovers), 170, 150, paint);

ksw87
  • 38
  • 5