我想讀取所有toc的所有內容。
你能告訴我如何閱讀內容表(toc)中的所有章節。
請發表修改後的代碼,以便我們可以閱讀所有內容或張貼一些內容以便閱讀。如何閱讀Android中的Epub文件的所有內容?
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);
}
}
}
什麼輸出所需的庫和
sampleepubfile.epub
你跟這個代碼的故事嗎? – GAMA可能的重複[如何閱讀所有內容根據智能章在Android](http://stackoverflow.com/questions/10895224/how-read-all-content-according-to-chapter-wise-in-android) – Barak
我想一個接一個的閱讀所有的章節。 – user1388681