admin管理员组

文章数量:1122926

电子书阅读器

实例包含了android手机可以运行的android电子书阅读器应用程序, 并附上源码,导入可以直接运行, 应用程序启动后首先是一个友好提示界面,3秒后消失进入主界面,主界面显示所有书籍列表, 点击列表观看书籍内容, 屏幕左侧点击向前翻页,右侧点击向后翻页, 并且显示当前页所在的书籍的百分比, 更多详情请观看视频

视频和demo下载地址:wisdomdd

视频中的源码可以点击【下载实例】进行下载, 环境配置: Eclipse+ADT+SDK4.0.3

android开发环境配置  .htm?resourceId=1028


程序启动后运行效果

    


代码讲解

1.启动界面

    firstActivity

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 public  class  firstActivity  extends  Activity {      /** Called when the activity is first created. */      @Override      public  void  onCreate(Bundle savedInstanceState) {          super .onCreate(savedInstanceState);          this .requestWindowFeature(Window.FEATURE_NO_TITLE);          getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,                  WindowManager.LayoutParams.FLAG_FULLSCREEN);          setContentView(R.layout.first);          AppConnect.getInstance( this );          Thread splashThread =  new  Thread() {              @Override              public  void  run() {                  try  {                      int  waited =  0 ;                      while  (waited <  5000 ) {                          sleep( 100 );                          waited +=  100 ;                      }                  catch  (InterruptedException e) {                      // do nothing                  finally  {                      finish();                      Intent i =  new  Intent();                      i.setClassName( "com.lxm.txtapp" ,                              "com.lxm.txtapp.MainActivity" );                      startActivity(i);                  }              }          };          splashThread.start();      }      /*       * (non-Javadoc)             * @see android.app.Activity#onResume()       */      @Override      protected  void  onResume() {          // TODO Auto-generated method stub          AppConnect.getInstance( this ).initPopAd( this );          super .onResume();      }; }

2. 主界面

   MainActivity

public  class  MainActivity  extends  Activity {      @Override      protected  void  onCreate(Bundle savedInstanceState) {          super .onCreate(savedInstanceState);          setContentView(R.layout.activity_main);          GridView gridView = (GridView) findViewById(R.id.popup_grid);          GridViewAdapter adapter =  new  GridViewAdapter( this , mPictures, mTitles,                  R.layout.grid2);          gridView.setAdapter(adapter);          // 互动广告调用方式          LinearLayout layout = (LinearLayout)  this                  .findViewById(R.id.AdLinearLayout);          AppConnect.getInstance( this ).showBannerAd( this , layout);          gridView.setOnItemClickListener( new  ItemClickListener());          gridView.setOnItemSelectedListener( new  OnItemSelectedListener() {              /*               * (non-Javadoc)                             * @see               * android.widget.AdapterView.OnItemSelectedListener#onItemSelected               * (android.widget.AdapterView, android.view.View, int, long)               */              @Override              public void onItemSelected(AdapterView<?> arg0, View arg1,                      int arg2, long arg3) {                  // TODO Auto-generated method stub              }              /*               * (non-Javadoc)                             * @see               * android.widget.AdapterView.OnItemSelectedListener#onNothingSelected               * (android.widget.AdapterView)               */              @Override              public  void  onNothingSelected(AdapterView<?> arg0) {                  // TODO Auto-generated method stub              }          });      }      private  int [] mPictures = { R.drawable.cover_txt, R.drawable.cover_txt,              R.drawable.cover_txt, R.drawable.cover_txt, R.drawable.cover_txt,              R.drawable.cover_txt, };      private  String[] mTitles = {  "Bookmarks" "Font Size" "Brightness" ,              "Read Style" "Recreation" "About"  };      public  static  String[] bookslist = {  "data.txt" "data1.txt" "data2.txt" ,              "data3.txt" "data4.txt" "data5.txt"  };      public  static  int [] bookslistid = { R.raw.data, R.raw.data1, R.raw.data2,              R.raw.data3, R.raw.data4, R.raw.data5 };      private  final  class  ItemClickListener  implements  OnItemClickListener {          @Override          public  void  onItemClick(AdapterView<?> parent, View view,  int  position,                  long  id) {              if  (position < bookslist.length) {                  Intent i =  new  Intent();                  i.setClassName( "com.lxm.txtapp" "com.lxm.txtapp.turntest" );                  i.putExtra( "bookname" , position);                  startActivity(i);              }          }      }      @Override      public  boolean  onCreateOptionsMenu(Menu menu) {          // Inflate the menu; this adds items to the action bar if it is present.          // getMenuInflater().inflate(R.menu.main, menu);          return  true ;      } }

书籍列表

public  static  String[] bookslist = {  "data.txt" "data1.txt" "data2.txt" ,              "data3.txt" "data4.txt" "data5.txt"  };

点击书籍列表后,展示的内容为data.txt, data1.txt .....   对应的文本内容




本文标签: 电子书阅读器