我不明白为什么会这样。我有以下代码:
AlertDialog.Builder builder = new AlertDialog.Builder(SettingsActivityNew.this);
builder.setTitle("Title");
builder.setSingleChoiceItems(R.array.example_arrays, 1, null);
builder.setNegativeButton("Cancel", null);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(SettingsActivityNew.this, "which: " + which, Toast.LENGTH_LONG).show();
}
});
builder.show();
出于某种奇怪的原因,int which 一直给我-1。为什么会这样?