0

スピナーを2つ持っています。それらの 1 つは、たとえば、stringarray の「countries」を、strings.xml から値「Russia」、「USA」などで表示します。また、国名の文字列配列があります。たとえば、文字列配列「ロシア」とその中のアイテム「モスクワ」、「ペンザ」などです。

ユーザーが国でアイテムを選択するとき、アイテムを文字列変数に入れ、それを R.array.{stringvariablevalue} のようなコード行で使用したい

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

私の英語でごめんなさい、そしてありがとう。

4

1 に答える 1

0
    int id = getResources().getIdentifier(countryName, "array", getPackageName());
    ArrayAdapter<CharSequence> spinneradapter = ArrayAdapter.createFromResource(this, id, android.R.layout.simple_spinner_item);
于 2013-07-03T09:36:18.590 に答える