在我的代码spinnerObj.setSelection(count)
中不行。我在谷歌搜索它,但没有找到答案。
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++;
}
这行(来自stackOverFlow)不起作用:
final int finalCount = count;
new Handler().postDelayed(new Runnable() {
public void run() {
detailsOptionSpinner.setSelection(finalCount);
detailsOptionSpinner.invalidate();
}
}, 13);
答案 0 :(得分:3)
您是否尝试使用两个参数设置微调器,第二个使用布尔值:
detailsOptionSpinner.setSelection(finalCount, true);
从它显示的developers page:
setSelection(int position, boolean animate)
//Jump directly to a specific item in the adapter data.