我想在用户点击spinner
框中的项目时显示一个确认框,其中包含选项"取消"和"确定"。在" ok"它应该更改spinner item
和"取消"它应该什么也不做。我无法执行此操作,因为OnClickListener
无法在Spinner
上工作。任何人都可以帮忙
答案 0 :(得分:0)
试试这个:
public class SpinnerActivity extends Activity implements OnItemSelectedListener {
...
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
// An item was selected. You can retrieve the selected item using
// parent.getItemAtPosition(pos)
// Now you can show your dialog
// And you can set the spinner previous selected item via
// spinnerObject.setSelection(previousIndex);
}
public void onNothingSelected(AdapterView<?> parent) {
// Another interface callback
}
}
您可以在此处了解有关微调器的更多信息http://developer.android.com/guide/topics/ui/controls/spinner.html和此处http://developer.android.com/reference/android/widget/Spinner.html