我要求过滤类别类型 - >类别 - >产品。为此,我必须像在eclipse包资源管理器中一样使用嵌套的微调器。
我怎样才能实现?
答案 0 :(得分:0)
看,我不确定你是否在寻找类似的东西。我有2个微调器,当用户从brandspinner中选择一个项目时,modelspinner会设置该品牌的所有产品。
private Spinner brandSpinner;
private Spinner modelSpinner;
brandSpinner = (Spinner)root.findViewById(R.id.brand_spinner);
modelSpinner = (Spinner)root.findViewById(R.id.model_spinner);
brandsAdapter = new ArrayAdapter<BrandItem>(mContext, android.R.layout.simple_spinner_dropdown_item, ArrayListWithBrands);
//I am not sure if it is needed:
brandsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
brandSpinner.setAdapter(brandsAdapter);
brandSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> a, View v, int pos, long id) {
//Harcoding Brands:
BrandItem brand = brandsArrHarcode.get(pos);
final ArrayList<String> modelsArr = brand.getModels();
modelsAdapter = new CustomArrayAdapter(mContext, android.R.layout.simple_spinner_dropdown_item, modelsArr);
modelsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
modelSpinner.setAdapter(modelsAdapter);
modelSpinner.setSelection(modelsAdapter.getPosition(camera.getModel()));
}
@Override
public void onNothingSelected(AdapterView<?> a) {}
}
);
希望有所帮助。