我正在使用http://www.siegmann.nl/epublib來讀取epub文件。我的代碼在下面提到。Android:Epub文件未在仿真器/ Android設備中顯示圖像
try {
book = epubReader.readEpub(new FileInputStream("/sdcard/EpubTesting.epub"));
Resource res;
Spine contents = book.getSpine();
List<SpineReference> spinelist = contents.getSpineReferences();
StringBuilder string = new StringBuilder();
String line = null;
int count = spinelist.size();
for (int i=0;i<count;i++){
res = contents.getResource(i);
try {
InputStream is = res.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
try {
while ((line = reader.readLine()) != null) {
linez = (string.append(line+"\n")).toString();
}
} catch (IOException e) {e.printStackTrace();}
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println(linez);
s1.loadDataWithBaseURL("/sdcard/",linez, "text/html", "UTF-8",null);
}catch (FileNotFoundException e) {
Toast.makeText(mContext, "File not found.", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(mContext, "IO Exception.", Toast.LENGTH_SHORT).show();
}
也試過
s1.loadDataWithBaseURL("",linez, "text/html", "UTF-8",null);
s1.loadDataWithBaseURL("file://mnt/sdcard/",linez, "text/html", "UTF-8",null);
但結果是sifar。請告訴我我必須做什麼來顯示文件中包含的圖像。我已經通過常見問題解答說讓一個android.webkit.WebView
的子類重載loadUrl(String)
方法,以便從圖書加載圖像而不是互聯網。但直到我不在他們提取文件的地方,我怎麼能找到路徑。請告訴我。我很困擾。提前致謝。
由於一噸格爾登,它的一個很好的示範。謝謝。但這裏有一個圖像沒有顯示的問題。你有關於這個問題的更新嗎? – 2013-12-30 12:09:08
css&圖像被下載到存儲/ sdcard0/books/images&..same path/css但不顯示在屏幕上。 css已成功應用。僅限圖片發行 – 2013-12-30 12:33:01
將圖書數據存儲到文件中。只在我的代碼中刪除評論。並將images和test.html文件放在同一個文件夾中,並在test.html中檢查問題 – 2013-12-30 12:43:16