【问题标题】:LayoutResultCallback() is not public in LayoutResultCallback; cannot be accessed from outside package error while generating pdfLayoutResultCallback() 在 LayoutResultCallback 中不公开;生成pdf时无法从外部包错误访问
【发布时间】:2017-06-14 19:53:21
【问题描述】:

我正在尝试在 android api 19 中打印 webview html。根据文档,在 api 级别 19 中添加了 PrintDocumentAdapter

https://developer.android.com/reference/android/print/PrintDocumentAdapter.html

https://developer.android.com/reference/android/print/PrintDocumentAdapter.LayoutResultCallback.html

但我得到 2 个错误

Error:(38, 64) error: LayoutResultCallback() is not public in LayoutResultCallback; cannot be accessed from outside package

Error:(42, 101) error: WriteResultCallback() is not public in WriteResultCallback; cannot be accessed from outside package

我的代码是

public void print(final PrintDocumentAdapter printAdapter, final File path, final String fileName) {
        printAdapter.onLayout(null, printAttributes, null, new PrintDocumentAdapter.LayoutResultCallback() {
            @Override
            public void onLayoutFinished(PrintDocumentInfo info, boolean changed) {

                printAdapter.onWrite(null, getOutputFile(path, fileName), new CancellationSignal(), new PrintDocumentAdapter.WriteResultCallback()
                {
                    @Override
                    public void onWriteFinished(PageRange[] pages) {
                        super.onWriteFinished(pages);
                        openHome();
                    }
                }
                );
            }

        }, null);
}

请尽快帮助。

【问题讨论】:

    标签: java android


    【解决方案1】:

    在您的 src 文件夹中创建一个包,名称为:android.print。然后用你的“打印”方法在那里创建一个文件。

    【讨论】:

      【解决方案2】:

      在此处创建文件夹android.print

      【讨论】:

        猜你喜欢
        • 2018-06-27
        • 1970-01-01
        • 1970-01-01
        • 2016-11-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多