How to know when user swipes to next page in PDFView? - Android

254 Views Asked by At

I'd like to ask about how to know when the user swipes to next page in PDFView in android.

pdfView = findViewById(R.id.pdfView);

pdfView.fromAsset("aday.pdf") .defaultPage(0) .enableSwipe(true) .load(); pdfView.setSwipeVertical(false);

when I use getPageCount(); it always returns 0. so what is the solution?

1

There are 1 best solutions below

0
On BEST ANSWER

In order to be notified when user has reached some page - try to register a listener:

pdfView.fromAsset("aday.pdf")
              .defaultPage(0)
              .enableSwipe(true)
              .onPageChange(new OnPageChangeListener() {
                     @Override
                     public void onPageChanged(int page, int pageCount) {
                        //page: the new page displayed, starting from 0
                     }
               }).load();