0
我试过这段代码,但是一个数组列表将被清除,但第二个数据不清楚请给我解决方案在第一个spinner清除spinner 2数据但是spinner 2 cant明确第三spinner数据请告诉我解决方案清除所有在spinner项目中的列表
我的数组列表
private ArrayList<String> students;
private ArrayList<String> teachers;
private ArrayList<String> CastName;
private ArrayList<String> SubCastName;
spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
spinnerreligiontext.setText(getNames(position));
stst = spinnerreligiontext.getText().toString();
System.out.println(getNames(position));
SubCastName.clear();
CastName.clear();
CastName();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
spinner2.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
aaa = getNamess(position);
System.out.println("spin2"+getNamess(position));
SubCastName.clear();
SubCastName();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
}); spinner3.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
aaa = getSubNamess(position);
System.out.println("spin3"+getSubNamess(position));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
一套适配器代码
for (int i = 0; i < j.length(); i++) {
try {
//Getting json object
JSONObject json = j.getJSONObject(i);
//Adding the name of the student to array list
students.add(json.getString("AllInOne"));
} catch (JSONException e) {
e.printStackTrace();
}
}
spinner1.setAdapter(new ArrayAdapter<String>(RagistarActivity.this, android.R.layout.simple_spinner_dropdown_item, teachers));