0

I am new in java. I have a clickable objects R.drawable.soccer or R.drawable.basketball in android app. When user click on image I know the string tag - "soccer" or "basketball". How to get access to object R.drawable.soccer_selected by string "soccer" ? Thanks

user2560165
  • 149
  • 1
  • 2
  • 15

1 Answers1

1

I'm not entirely sure I understand your question. Are you trying to get the Drawable soccer_selected?

if( myString.equalsIgnoreCase( "soccer" ) ){
    Drawable d = getResources().getDrawable( R.id.soccer_selected );
}
AkiAki007
  • 429
  • 3
  • 16
  • Thanks for answer, I mean, for example in javascript I can get access to object's property by a string or variable - R.id["soccer"] - that equal to R.id.soccer, how to do the same in java? – user2560165 May 22 '14 at 08:29