Hello guys,

I have the following question.
I need to use R.drawable.id's dinamicaly, depending on the country
choosen, more precisely,depending on a "country" variable.
For example, my screen contains a country flag. If the Deutschaland is
the choosen country, i have to display  something like this:

    ImageView  flag;
    flag=(ImageView)findViewById(R.id.ImageView01);
    flag.setBackgroundResource(R.drawable.flag_de);

  Inside android application, in "res/drawable-hdpi"  i have saved all
needed flags with the following names: flag_de.jpg,  flag_uk.jpg,
flag_ro.jpg  and so on.

How can i set background image for this "flag" value dynamically?????
If i use the following  way, there are too mush code:

if (country.equals("DE") {
              flag.setBackgroundResource(R.drawable.flag_de);
} else if (country.equals("UK")) {
              flag.setBackgroundResource(R.drawable.flag_uk);
} else if (country.equals("RO")) {
            flag.setBackgroundResource(R.drawable.flag_ro);
}

I want to create somehow "R.drawable.flag" by appending the country
extension "de" .

String countryFlag="flag_"+mySource.countryExtension ;     //something
like flag_DE
countryFlag=countryFlag.toLowerCase();                              //
=flag_de
flag.setBackgroundResource(R.drawable.countryFlag);       // of
course, it's not working


Could anyone give me a suggestion please ?
Thank you
Lidy

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to