【问题标题】:how to open a pdf from sdcard and display in fragment android如何从sdcard打开pdf并在片段android中显示
【发布时间】:2015-05-28 07:35:58
【问题描述】:

我正在实现一个平板电脑应用程序,它在左侧显示我的 pdf 文件列表,在右侧我想显示 pdf 文件数据。我怎样才能做到这一点?我想在片段中打开 Pdf。 要求: 1.应该从本地文件加载PDF。 2. 必须能够在 Android 中使用 Fragments 打开 PDF。

【问题讨论】:

    标签: android android-layout pdf android-fragments android-activity


    【解决方案1】:

    您可以使用诸如android-pdfview 之类的库来显示 PDF 文件。

    【讨论】:

      【解决方案2】:

      如果您的 android 最低支持版本是 api level 21,您可以使用 android PdfRenderer

      【讨论】:

        【解决方案3】:
        String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/yourfolder";
        File file = new File(path,"file.pdf"); 
        

        在你的清单中添加这一行

        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> 
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        

        【讨论】:

        • 在你的 Manifest 添加这行 跨度>
        猜你喜欢
        • 2019-09-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-12
        • 1970-01-01
        • 2015-07-22
        • 2015-12-18
        • 2016-11-06
        相关资源
        最近更新 更多