我尝试使用spinner
从JSON
响应中填充多个retrofit
。
在JSON
回复中,我提取了所有细节。我填充了spinner1。
如何根据第一个spinner
选择填充其余的微调器。
Spinner1,Spinner2,Spinner3。
在Spinner1中选择项目时,应填充Spinner2
在Spinner2中选择项目时,应填充Spinner3。
ExpertSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
@Override
public void onSuccess(Response response, GlobalVariables.SERVICE_MODE mode) {
switch (mode) {
case AGRI_EXPERTS:
try {
List<CC_AgriExpertModel> expert = (List<CC_AgriExpertModel>) response.body();
ArrayList<String> productList = new ArrayList<>();
for (int i = 0; i < expert.size(); i++)
{
productList.add(expert.get(i).getExpert_name());
}
ArrayAdapter<String> adapter1;
adapter1 = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, productList);
//setting adapter to spinner
ExpertSpinner.setAdapter(adapter1);
adapter1.notifyDataSetChanged();
} catch (Exception e) {
e.printStackTrace();
}
break;
}
}