我正在使用这个epub 文件,我正在使用的代码是
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AssetManager assetManager = getAssets();
try {
// find InputStream for book
InputStream epubInputStream = assetManager.open("widget.epub");
System.err.println("epubInputStream>>"+epubInputStream);
// 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());
// Log the book's coverimage property
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);
} catch (IOException e) {
Log.e("epublib", e.getMessage());
}
}
private void logTableOfContents(List<TOCReference> tocReferences, int depth) {
if (tocReferences == null) {
return;
}
for (TOCReference tocReference : tocReferences) {
StringBuilder tocString = new StringBuilder();
for (int i = 0; i < depth; i++) {
tocString.append("\t");
}
tocString.append(tocReference.getTitle());
Log.i("epublib", tocString.toString());
logTableOfContents(tocReference.getChildren(), depth + 1);
}
}
}
我的xml是::
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
</RelativeLayout>
我的 Logcat 显示每个日志,没有任何错误
02-04 15:12:46.839: D/dalvikvm(26799): WAIT_FOR_CONCURRENT_GC blocked 6ms
02-04 15:12:46.849: I/epublib(26799): author(s): [Starr, E.L.]
02-04 15:12:46.849: I/epublib(26799): title: EPUB Widgets: Figure Gallery
02-04 15:12:46.879: D/dalvikvm(26799): GC_FOR_ALLOC freed 152K, 7% free 8209K/8788K, paused 24ms, total 24ms
02-04 15:12:46.889: I/dalvikvm-heap(26799): Grow heap (frag case) to 11.828MB for 3813392-byte allocation
02-04 15:12:46.919: D/dalvikvm(26799): GC_FOR_ALLOC freed <1K, 5% free 11933K/12516K, paused 24ms, total 24ms
02-04 15:12:46.929: D/dalvikvm(26799): GC_CONCURRENT freed <1K, 5% free 11932K/12516K, paused 3ms+2ms, total 18ms
02-04 15:12:46.979: I/epublib(26799): Coverimage is 1024 by 931 pixels
02-04 15:12:46.979: I/epublib(26799): Phases of the Moon
02-04 15:12:47.019: D/libEGL(26799): loaded /system/lib/egl/libEGL_tegra.so
02-04 15:12:47.059: D/libEGL(26799): loaded /system/lib/egl/libGLESv1_CM_tegra.so
02-04 15:12:47.059: D/libEGL(26799): loaded /system/lib/egl/libGLESv2_tegra.so
02-04 15:12:47.079: D/OpenGLRenderer(26799): Enabling debug mode 0
我只能HelloWorld
在屏幕上显示而不是在 epub 内容上显示!!如何显示 epub 内容?