如何更新适配器?

问题描述:

我在班上有几个纺纱工。 对于第一个微调我有一组数据。 其他spiners将根据选择的拳头微调器从服务器下载数据。 但是,在下载数据后,它不会更新微调控制器适配器。如何更新适配器?

适配器第二微调:

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

'adapterSection.clear(); adapterSection.addAll(data);' – Selvin 2013-04-10 12:56:15

+0

没有帮助 – Yarh 2013-04-10 13:05:47

+1

所以'data'没有元素... – Selvin 2013-04-10 13:08:23

你需要清洁适配器,然后添加项目和:从fisrts微调onItemSelected,我认为应该更新适配器

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); 

代码示例通知。

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

希望它的帮助。

+0

+1在“阅读评论”技能中......并且... ... +2在“将其他用户评论重写为答案”技能中......你已经进入下一个等级。 ..'adapterSection.notifyDataSetChanged();'?做什么的 ?它已在'addAll'中调用... – Selvin 2013-04-10 13:06:32