0

I have a document in the Firebase storage. I want to open that document and display it using an alert dialog and a PDFView from the pdf-viewer:2.8.2 library. This doesen't work when the setPositiveButton is clicked. Any ideas on what I might be doing wrong? This is the code am writing.

 holder.postDocument.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final AlertDialog.Builder builder = new AlertDialog.Builder(mContext, R.style.AlertDialog);
            builder.setTitle("Open the document?");
            builder.setPositiveButton("Open", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, int which) {

                   final PDFView pdfView = new PDFView(mContext, null);
                   pdfView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
                   pdfView.fromAsset(post.getPostdocument());
                   pdfView.loadPages();
                   builder.setView(pdfView);

                    
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });

            builder.show();
        }
    });
4

1 回答 1

0

您可以轻松找到解决方案并粘贴到警报对话框中https://github.com/eduxcellence/PDFViewer/find/master

于 2020-08-28T18:57:04.910 回答