在 listview alertdialog 的 switch case 中选择一个项目后,如何将值保存到 textview,谢谢
final AlertDialog.Builder builder = new
AlertDialog.Builder(FlightActivity.this);
builder.setTitle("Pilih Kota Asal");
// add a list
final String[] asalkota = {"Jakarta", "Medan", "Palembang", "Bandung",
"Yogyakarta", "Palu", "Makassar", "Padang", "Surabaya", "Palangkaraya",
"Solo", "Denpasar", "Madura"};
builder.setItems(asalkota, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
kotaAsalFlight.setText(asalkota.toString());
}
}
});
AlertDialog dialog = builder.create();
dialog.show();
}