2017-06-14 122 views
2

我試圖打印網頁視圖的HTML在機器人API 19. PrintDocumentAdapter根據文檔在API級別19添加被訪問LayoutResultCallback()在LayoutResultCallback中不公開;不能從外部包錯誤而生成PDF

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); 
} 

請需要儘快幫助。

回答

1

在名爲android.print的src文件夾內創建一個包。然後用你的「打印」方法在那裏創建一個文件。

相關問題