首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >公共课程不公开?

公共课程不公开?
EN

Stack Overflow用户
提问于 2017-02-15 13:14:27
回答 1查看 1.8K关注 0票数 0

我试图使用以下代码的一部分:https://github.com/androidsrc/PdfReadWrite/tree/master/app

更确切地说,这一部分:

代码语言:javascript
复制
   public class PdfGenerationTask extends AsyncTask<Void, Void,String>{

        protected String doInBackground(Void... params) {
            PdfDocument document = new PdfDocument();
            View author = findViewById(R.id.author);
            int pageNumber = 1;
            PdfDocument.PageInfo pageInfo = new PdfDocument.PageInfo().Builder(20,20,pageNumber).create();
            PdfDocument.Page page = document.startPage(pageInfo);
            author.draw(page.getCanvas());
            document.finishPage(page);
            String pdfName = "pdfdemo";
            File outputFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS));
            try {outputFile.createNewFile();
                OutputStream out = new FileOutputStream(outputFile);
                document.writeTo(out);
                document.close();
                out.close();

        }
            catch (IOException e) {
                e.printStackTrace();
            }
            return outputFile.getPath();
    }

当我在Android中运行这个程序时,我会得到几个错误介面,第一个是:Error:(44, 45) error: PageInfo() is not public in PageInfo; cannot be accessed from outside package。我已将PdfGEneration任务更改为公共任务,但这似乎无法解决问题。我该怎么做,为什么?

第二个错误是这个:Error:(49, 31) error: no suitable constructor found for File(File) constructor File.File(String) is not applicable (argument mismatch; File cannot be converted to String) constructor File.File(URI) is not applicable (argument mismatch; File cannot be converted to URI),这里的问题是什么?我能做些什么来解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2017-02-15 13:33:05

看起来PageInfo构造函数是私有的。而不是

新PdfDocument.PageInfo().Builder(20,20,pageNumber).create();

试一试

新PdfDocument.PageInfo.Builder(20,20,pageNumber).create();

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42250429

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档