android根据其他微调器更改微调器列表

android根据其他微调器更改微调器列表,android,arrays,spinner,Android,Arrays,Spinner,我的活动中有几个旋转器 是否可以根据微调器1上选择的项目更改微调器2的内容 微调器如下所示 <Spinner android:id="@+id/spinner1" android:layout_width="0sp" android:layout_weight="0.6" android:layout_height="wrap_content" android:layou

我的活动中有几个旋转器

是否可以根据微调器1上选择的项目更改微调器2的内容

微调器如下所示

          <Spinner
          android:id="@+id/spinner1"
          android:layout_width="0sp"
          android:layout_weight="0.6"
          android:layout_height="wrap_content"
          android:layout_marginLeft="10sp"
          android:layout_marginTop="10sp"
          android:contentDescription="Fred"
          android:entries="@array/country_arrays"
          android:prompt="@string/country_prompt" />


      <Spinner
      android:id="@+id/spinner2"
      android:layout_width="0sp"
      android:layout_weight="0.4"
      android:layout_height="wrap_content"
      android:layout_marginLeft="10sp"
      android:layout_marginTop="10sp"
      android:contentDescription="Fred"
      android:entries="@array/country_arrays2"
      android:prompt="@string/country_prompt2" />

如果在微调器1上选择了项目3,如何将微调器2中的国家/地区数组2中的条目更改为国家/地区数组3

谢谢你的帮助


在java活动文件中标记,可以通过编程方式加载微调器内容:

    Spinner miSpinner = (Spinner) findViewById("spinner2");

    ArrayAdapter<String> tiposElementos = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item);
    tiposElementos.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    for(int i=0; i<20; i++) {
        tiposElementos.add("Element" + i);
    }

    miSpinner.setAdapter(tiposElementos); 
Spinner miSpinner=(微调器)findViewById(“微调器2”);
ArrayAdapter tiposElementos=新的ArrayAdapter(这是android.R.layout.simple\u微调器\u项);
tiposElementos.setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
对于(int i=0;i父项){}
};
miSpinner.setOnItemSelectedListener( new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parent, View v, int index, long id) {
        your code
    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) { }
};