所以我的应用程序有可以动态添加的微调器,它们是从一个巨大的Course对象数组列表中填充的,如下所示courseSpinner = rowView.findViewById(R.id.first_spinner); ArrayAdapter<Course> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, courseList); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); courseSpinner.setAdapter(adapter); parentLayout.addView(rowView, parentLayout.getChildCount() - 1); allSpinners.add(courseSpinner); //this is an ArrayList of spinners that keeps track of how many spinners exist currently since like mentioned before they can be dynamically added or removed我想删除从每个新生成的微调器中按下按钮后选择的值。按下按钮时,会将值保存到单独的哈希映射中,并删除所有现有的微调器,但我需要实现某种将被调用的更新方法,该方法将从courseList微调器获取其值的位置重新填充或减去值。任何帮助表示赞赏
1 回答
萧十郎
TA贡献1815条经验 获得超13个赞
这是带有适配器和列表的微调器:
ArrayAdapter<String> arrayAdapter;
arrayAdapter= new ArrayAdapter<String>(this, R.layout.spinner_indication, yourList);
Spinner yourSpinner;
yourSpinner.setAdapter(arrayAdapter)
从旧列表创建的新列表将其设置为适配器,如下所示:
yourList = newGeneratedList ;
arrayAdapet.notifyDataSetChanged();
添加回答
举报
0/150
提交
取消