旋转器触发另一个旋转器

时间:2012-10-12 02:11:49

标签: java android android-spinner

mySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
        // my code here, but I don't know how..
    }
}

我认为会是这样的:

  1. 获取mySpinner的所选项目位置
  2. switch(pos)
  3. 更新微调器条目?我不知道......
  4. 我不知道该怎么办才能完成最后一步。帮助

1 个答案:

答案 0 :(得分:0)

以这种方式尝试

    car.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) {
            itemSelected = arg2;
              // add items to the cardetails spinner's adapter using the itemselected  and refresh the adapter using nofifyDataSetChanged()
        }

        public void onNothingSelected(AdapterView<?> arg0) {

        }
    });
    cardetails.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) {

        }

        public void onNothingSelected(AdapterView<?> arg0) {

        }
    });

这里的汽车和cardetails都是旋转器 您需要刷新与汽车微调器相关的适配器,以便微调器也可以刷新