0

我在一个班上有几个旋转器。对于第一个微调器,我有一组数据。其他 spinner 将根据第一个 spinner 的选择从服务器下载数据。但是,下载数据后,它不会更新微调器适配器。

第二个微调器的适配器:

sectionField = new String[] {"Error"};
            adapterSection = new ArrayAdapter<String>(
                    this, android.R.layout.simple_spinner_item, sectionField);
            adapterSection
                    .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            section.setAdapter(adapterSection);

来自 fisrts spinner 的代码示例onItemSelected,我认为应该更新适配器:

sectionField = new String[data.length()];
sectionField = data;
section.setVisibility(View.VISIBLE);
adapterSection.notifyDataSetChanged();
4

1 回答 1

0

您需要清洁适配器,然后添加项目并通知。

adapterSection.clear();
adapterSection.addAll(data);
adapterSection.notifyDataSetChanged();

希望有帮助。

于 2013-04-10T12:58:36.097 回答