gpt4 book ai didi

java - 如何在android中根据Chapter wise阅读所有内容

转载 作者:行者123 更新时间:2023-11-29 09:13:36 24 4
gpt4 key购买 nike

我可以阅读一章的内容,但我想阅读所有章节的内容,请告诉我如何阅读页码。

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);
}
}
}

最佳答案

@user1388681 我遇到了同样的问题,但我解决了。请参阅我对此的回答 Can't display table of contents or entire book on the screen

关于java - 如何在android中根据Chapter wise阅读所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10895224/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com