我正在使用afollestad MaterialDialog Libraryhttps://github.com/afollestad/material-dialogs
 并使用自定义视图。内部视图中有五个输入和微调框。但是我试图从输入中获取价值,但是没有用。另外,我需要从api填充微调框。

   MaterialDialog dialog = new MaterialDialog.Builder(this)
                .title("Edit Paid Amount")
                .customView(R.layout.edit_payment_model, true)
                .positiveText("Update Payment").build();
Spinner spinner= (Spinner) dialog.getCustomView();
 dialog.show();


谁能帮助我实现这一目标?

我已经尝试过默认警报对话框

 AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
        LayoutInflater inflater = this.getLayoutInflater();

        View dialogView= inflater.inflate(R.layout.edit_payment_model, null);
        dialogBuilder.setView(dialogView);
        EditText editText = (EditText)
                dialogView.findViewById(R.id.editPaymentAmount);

        editText.setText("test label");
        dialogBuilder.create().show();


甚至我检查了这个问题https://github.com/afollestad/material-dialogs/issues/230

最佳答案

我对这个lib不熟悉,但是您应该在自定义视图中找到spinner / edittext视图。

    MaterialDialog dialog = new MaterialDialog.Builder(this)
                    .title("Edit Paid Amount")
                    .customView(R.layout.edit_payment_model, true)
                    .positiveText("Update Payment")
                    .build();

    View customView = dialog.getCustomView();
    Spinner spinner = (Spinner) customView.findViewById(R.id.spinner)
    EditText editText = (EditText) customView.findViewById(R.id.editPaymentAmount);
    editText.setText("test label");
    dialog.show();

10-02 04:25