Make your country some king of pair <country,flag> and when you select country just set country.getflag() as background.
On Wed, Aug 25, 2010 at 12:01 PM, Lidy <lidyp...@yahoo.com> wrote: > 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 android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- When I raise my flashing sword, and my hand takes hold on judgment, I will take vengeance upon mine enemies, and I will repay those who haze me. Oh, Lord, raise me to Thy right hand and count me among Thy saints. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en