Reputation: 852
In my code spinnerObj.setSelection(count)
dont work. I search it in google and dont find answer for me.
count = 0;
repairDetailsAdapter = new RepairDetailsAdapter(this, R.layout.gas_station_spinner_item, details);
detailsOptionSpinner.setAdapter(repairDetailsAdapter);
for (RepairDetail detail : details) {
if (detail.getId() == tempDetail.getId()) {
detailsOptionSpinner.setSelection(count);
detailsOptionSpinner.invalidate();
break;
}
count++;
}
This lines (from stackOverFlow) dont work:
final int finalCount = count;
new Handler().postDelayed(new Runnable() {
public void run() {
detailsOptionSpinner.setSelection(finalCount);
detailsOptionSpinner.invalidate();
}
}, 13);
Upvotes: 2
Views: 5472
Reputation: 18386
Have you tried to set the spinner by using two arguments, the second using a boolean:
detailsOptionSpinner.setSelection(finalCount, true);
From the developers page it shows:
setSelection(int position, boolean animate)
//Jump directly to a specific item in the adapter data.
Upvotes: 3