Android 将AlertDialog与setCursor一起使用时正确管理光标

Android 将AlertDialog与setCursor一起使用时正确管理光标,android,cursor,android-alertdialog,Android,Cursor,Android Alertdialog,考虑以下代码: private View.OnClickListener mTemplateButtonListener = new View.OnClickListener() { public void onClick(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(NewMailActivity.this); buil

考虑以下代码:

private View.OnClickListener mTemplateButtonListener = new View.OnClickListener()
    {
        public void onClick(View view)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(NewMailActivity.this);
            builder.setTitle(getString(R.string.str_new_mail_activity_choose_template));

            final Cursor c = MailData.getTemplateCursor();

            builder.setCursor(c, new DialogInterface.OnClickListener()
            {
                public void onClick(DialogInterface dialog, int item)
                {
                    c.moveToPosition(item);
                    et_body.setText(c.getString(c.getColumnIndex(MailData.TEMPLATES_TABLE_COL_BODY)));
                    et_subject.setText(c.getString(c.getColumnIndex(MailData.TEMPLATES_TABLE_COL_SUBJECT)));
                }
            }, MailData.TEMPLATES_TABLE_COL_SUBJECT);

            templatesAlertDialog = builder.create();
            templatesAlertDialog.show();
        }
    };
我使用它在AlertDialog中显示模板列表

使用
MailData.getTemplateCursor()
加载数据的游标查询SQLite数据库中的数据。我无法找到关闭光标的正确位置,因为如果我这样做,我就不会得到任何数据

例如,有没有办法用ArrayList填充AlertDialog


编辑:我发现了一个使用ListAdapter的解决方案,但它需要布局等,使其变得不必要的复杂。还有其他解决办法吗

关于Disclose listener呢?如何添加Disclose listener?setOnDismissListener?