Java 如何在android中按照章节阅读所有内容
我能阅读一章的内容,但我想阅读所有章节的内容,请告诉我如何阅读页码Java 如何在android中按照章节阅读所有内容,java,android,Java,Android,我能阅读一章的内容,但我想阅读所有章节的内容,请告诉我如何阅读页码 public class LogTestBookInfo extends Activity { ExpandableListView list; TextView txt1; WebView web1; ImageView img1; /** Called when the activity is first created. */ @Override public v
public class LogTestBookInfo extends Activity {
ExpandableListView list;
TextView txt1;
WebView web1;
ImageView img1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AssetManager assetsmanger = getAssets();
try {
// find InputStream for book
InputStream epubInputStream = assetsmanger
.open("books/INCOME-TAX-ACT-1961.epub");
// Load Book from inputStream
Book book = (new EpubReader()).readEpub(epubInputStream);
// Log the book's authors
Log.i("epublib", "author(s): " + book.getMetadata().getAuthors());
// Log the book's title
Log.i("epublib", "title: " + book.getTitle());
// String data=new String (book.getContents().get(3).getData());
// String k=data;
web1 = (WebView) findViewById(R.id.webView1);
// txt1=(TextView) findViewById(R.id.textView1);
// txt1.setText(k);
// web1.loadData(k," text/html", "utf8");
Bitmap coverImage = BitmapFactory.decodeStream(book.getCoverImage()
.getInputStream());
Log.i("epublib", "Coverimage is " + coverImage.getWidth() + " by "
+ coverImage.getHeight() + " pixels");
// Log the tale of contents
logTableOfContents(book.getTableOfContents().getTocReferences(), 0);
// list=(ExpandableListView)findViewById(R.id.expandableListView1);
// img1=(ImageView)findViewById(R.id.imageView1);
//
//
// img1.setImageBitmap(coverImage);
//
//
} catch (IOException e) {
// TODO Auto-generated catch block
Log.e("epublib", e.getMessage());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void logTableOfContents(List<TOCReference> tocReferences, int depth) {
// TODO Auto-generated method stub
if (tocReferences == null) {
return;
}
for (TOCReference tocReference : tocReferences) {
StringBuilder tocstring = new StringBuilder();
for (int i = 0; i < depth; i++) {
tocstring.append("\t");
}
HashMap<String, String> map = new HashMap<String, String>();
String k = tocstring.append(tocReference.getTitle()).toString();
map.put("TOC", k);
ArrayList<HashMap<String, String>> list1 = new ArrayList<HashMap<String, String>>();
list1.add(map);
String t = k;
Log.i("epublib", tocstring.toString());
logTableOfContents(tocReference.getChildren(), depth + 1);
}
}
}
公共类LogTestBookInfo扩展活动{
可扩展列表视图列表;
TextView txt1;
WebView-web1;
ImageView img1;
/**在首次创建活动时调用*/
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AssetManager AssetManager=getAssets();
试一试{
//查找书籍的输入流
InputStream epubInputStream=资产管理器
.公开(“账簿/所得税法案-1961.epub”);
//从inputStream加载图书
BookBook=(新的EpubReader()).readEpub(epubInputStream);
//记录这本书的作者
Log.i(“epublib”,“作者:”+book.getMetadata().getAuthors());
//记录书名
Log.i(“epublib”,“title:+book.getTitle());
//字符串数据=新字符串(book.getContents().get(3.getData());
//字符串k=数据;
web1=(WebView)findviewbyd(R.id.webView1);
//txt1=(TextView)findViewById(R.id.textView1);
//txt1.setText(k);
//web1.loadData(k,“text/html”,“utf8”);
位图coverImage=BitmapFactory.decodeStream(book.getCoverImage()
.getInputStream());
Log.i(“epublib”,“Coverimage是”+Coverimage.getWidth()+“by”
+coverImage.getHeight()+“像素”);
//记录内容的故事
内容日志表(book.getTableOfContents().gettoReferences(),0);
//列表=(ExpandableListView)findViewById(R.id.expandableListView1);
//img1=(ImageView)findViewById(R.id.imageView1);
//
//
//img1.setImageBitmap(封面图像);
//
//
}捕获(IOE异常){
//TODO自动生成的捕捉块
Log.e(“epublib”,e.getMessage());
}捕获(例外e){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
}
内容的私有void日志表(列表引用,int深度){
//TODO自动生成的方法存根
if(tocpreferences==null){
回来
}
for(TOCReference TOCReference:tocReferences){
StringBuilder tocstring=新的StringBuilder();
for(int i=0;i
@user1388681我也面临同样的问题,但我解决了。看到我的答案了吗?@user1388681我也面临同样的问题,但我解决了。看到我的答案了吗