demo library 下载

Activity调用的方法

public class PDFActivity extends Activity implements OnPageChangeListener {public static final String PDF_NAME = "xxx.pdf";// 书名private PDFView pdfView;private TextView pdf_tv_num;private int bookPage = 1;public final static String BOOKID = "bookId";@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_pdf);pdfView = (PDFView) findViewById(R.id.pdfView);pdf_tv_num = (TextView) findViewById(R.id.pdf_tv_num);String bId = mCache.getAsString("pdfPage");// 获取上次读取的页数if (!isNEB(bId)) {bookPage = Integer.parseInt(bId);}String path = activity.getFilesDir().getAbsolutePath();// 获取路径File file = new File(path, PDF_NAME);if (file.exists()) {pdfView.fromFile(file).defaultPage(bookPage).onPageChange(this).load();// 显示要看的第几页}}public void onPageChanged(int page, int pageCount) {bookPage = page;pdf_tv_num.setText(page + "/" + pageCount);// page正在看的页数,pageCount总页数}@Overrideprotected void onStop() {super.onStop();// TODO 这里先保存的页数  bookPage// 如果退出要删除pdf,执底下的代码,否则不需要String path = activity.getFilesDir().getAbsolutePath();File file = new File(path, PDF_NAME);if (file.exists()) {file.delete();finish();}}}
布局

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent" >    <com.joanzapata.pdfview.PDFView        android:id="@+id/pdfView"        android:layout_width="match_parent"        android:layout_height="match_parent"/>    <TextView        android:id="@+id/pdf_tv_num"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentBottom="true"        android:layout_centerHorizontal="true"        android:layout_marginBottom="10dp"        android:textColor="#000000"        android:textSize="12sp" /></RelativeLayout>
demo library 下载

更多相关文章

  1. 【阿里云镜像】切换阿里巴巴开源镜像站镜像——Debian镜像
  2. Android(安卓)经典小技巧总结
  3. Android获取ROOT权限
  4. Android(安卓)获取url中的参数
  5. 2010.12.26——— android 获得手机号码 和 IMEI号 等
  6. Android(安卓)经典小技巧总结
  7. Android获取当前网络状态和获取当前设备网络ip地址
  8. eclipse中安装android ADT插件及无法下载ADT解决方法
  9. android TextUtils的使用

随机推荐

  1. Swoole自定义项目初始化事件处理的实现
  2. PHP怎么把JSON转换成数组?
  3. web安全之文件上传漏洞攻击与防范方法
  4. php用什么软件编程
  5. register_shutdown_function 函数详解
  6. 学php看什么书
  7. phpcms网站程序如何安装新的模板
  8. memcache安全相关
  9. PHP生成中文验证码并检测对错实例
  10. 如何安装phpmyadmin