0

I have two spinners. One of them, for exmaple display stringarray "countries" from strings.xml with values "Russia", "USA" and so on. Also i have stringarray with the name of country, for exmaple stringarray "Russia" and items in it "Moscow", "Penza" and so on.

When user select an item in countries i want to put item to a string variable and use it in my code line like R.array.{stringvariablevalue}

    ArrayAdapter<CharSequence> spinneradapter = ArrayAdapter.createFromResource(this, R.array.{selectedItem value must be here}, android.R.layout.simple_spinner_item);

sorry for my English, and thank You.

oybek
  • 57
  • 1
  • 7
  • 1
    http://stackoverflow.com/questions/3042961/how-can-i-get-the-resource-id-of-an-image-if-i-know-its-name ... but at your place I would use the database – Selvin Jul 03 '13 at 09:21

1 Answers1

0
    int id = getResources().getIdentifier(countryName, "array", getPackageName());
    ArrayAdapter<CharSequence> spinneradapter = ArrayAdapter.createFromResource(this, id, android.R.layout.simple_spinner_item);
oks16
  • 1,294
  • 11
  • 16