有人能指出一個自定義對話框的示例,它將ArrayAdapter作爲輸入並顯示可選列表。Android自定義列表對話框
我曾嘗試使用AlertDialog Builder作爲這樣來創建一個對話框......
final ArrayAdapter<MyObject> myAdapter = getMyobjects();
final AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("Pick an item").setAdapter(myAdapter,
new android.content.DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, final int item) {
Toast.makeText(Islands.this, myAdapter.getItem(item).toString(), Toast.LENGTH_SHORT).show();
}
});
final AlertDialog alert = builder.create();
return alert;
我的問題是,我的對話並沒有更新的話,我叫
@Override
protected void onPrepareDialog(final int id, final Dialog dialog) {
switch (id) {
case DIALOG_GET_AVAIL_DESTS:
((AlertDialog) dialog).getListView().setAdapter(getDestinations());
break;
}
}
然而聽衆的onClick聽最初的一套物品...