public void setId(int id) { int position; AEntity aEntity; position = 0; for (t entity : _spinnerAdapter.getList()) { aEntity = (AEntity) entity; // uncomfortable cast (Ensure entity has inherited from AEntity) if (id == aEntity.getId()) break; position++; } if (position >= _spinnerAdapter.getList().size()) position = 0; // just in-case it's not found _spinner.setSelection(position); }
public t getSelectedItem() { int pos; pos = _spinner.getSelectedItemPosition(); return _spinnerAdapter.getItem(pos); }