按下后退键后,我实现了此代码以恢复我在 PDF 文档中最后打开的页面。不幸的是,它仍然加载第一页。
pdfView1 = findViewById(R.id.pdfViewer1);
pdfView1.fromAsset("cpgTest1.pdf")
.scrollHandle(new DefaultScrollHandle(this))
.defaultPage(currentPage)
.onPageChange(this)
.load();
}
@Override
public void onPageChanged(int page, int pageCount)
{
currentPage = page;
}
@Override
public void loadComplete(int nbPages)
{
if (currentPage >= 0)
{
pdfView1.jumpTo(currentPage);
}}
@Override
public void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
outState.putInt(KEY_CURRENT_PAGE, currentPage);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState)
{
super.onRestoreInstanceState(savedInstanceState);
currentPage = savedInstanceState.getInt(KEY_CURRENT_PAGE);
}
}
任何想法?