How to open a PDF file in listview items?

Asked

Viewed 169 times

0

I created an Arraylist list and wanted to open pdf files in it, but I am storing the pdf files in res/raw folder and when calling in String ("res/raw") the file just doesn’t open, which I do?

  • My suggestion is to use some library with good reputation to render the PDF, has a list available on android arsenal: https://android-arsenal.com/tag/72?sort=rating with various options.

  • Yes, but how to add the pdf in Array?

  • The ideal is for you to access Inputstream, using the context.getResources().openRawResource(R.raw.nome_do_pdf). Do you want to open all Arrayslist Pdfs at the same time or just one at a time? I recommend looking at the library documentation, how it expects you to pass the PDF to it to render, because it can vary a lot.

  • I want to open a different pdf for each click of the Array, the problem is that when I click on the list item, the pedf does not appear, it simply appears a white screen.

  • Look I put it this way to access:New Pdfview = (Pdfview) findViewById(pdfView); new.fromAsset("text.pdf"). load();

  • But it shows a blank screen and in the log appears the following message:05-19 16:47:44.637 23878-23878/com.example.android.contos V/Activitythread: updateVisibility : Activityrecord{4ca7407 token=android.os.Binderproxy@c 905bfe {com.example.android.contos/com.example.android.contos.Mainactivity}} show : false

  • This error doesn’t help much, it would be good to tell which lib is using, and shouldn’t pass the Resource id instead of a String?

  • I got Wakim, know what it was, I was putting in the raw folder, just change the pdf file to the Assets folder and put it in the main folder, which worked, will understand!

  • Cool, I thought inside raw would also work :( Could include an answer with this adjustment.

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.