Look, I am not sure if you are looking for something like that. I have 2 spinner, when the user select a item from brandspinner, the modelspinner is setted with all the products of this brand.
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) {}
}
);
Hope to be helpful.