0

リストビューに正常にバインドしているデータベースから結果を取得するコードを記述しましたが、カスタムダイアログ形式でそのリストビューが必要です。つまり、リストデータがダイアログに表示されます。リストデータをカスタムダイアログボックスにアタッチする方法?

final Cursor cursor = dbHelper.fetchAllRecords();
        String[] columns = new String[] {
                RecordsDbAdapter.KEY_NAME,
                RecordsDbAdapter.KEY_BIRTHDAY,

        };
        int[] to = new int[] {
                R.id.name,
                R.id.birthdate,
        };
        dataAdapter = new SimpleCursorAdapter(
                this, R.layout.row,
                cursor,
                columns,
                to);
        ListView listView = (ListView) findViewById(R.id.list);
        listView.setAdapter(dataAdapter);
4

1 に答える 1

0

AlertDialogアダプターを:にバインドできます。

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setAdapter(dataAdapter, new DialogInterface.OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int which) {

        // Stuff that happens when an item is clicked
    }
});
builder.show();
于 2012-10-30T06:24:59.217 に答える