问题描述
我从http://www.siegmann.nl/epublib/download 我想将此代码显示到我的webview中 我是初学者
class Kotlin : AppCompatActivity() {
lateinit var webView: WebView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_kotlin)
webView=findViewById(R.id.kotlinwebview)
val assetManager = assets
try {
// find InputStream for book
val epubInputStream = assetManager
.open("books/testbook.epub")
// Load Book from inputStream
val book = EpubReader().readEpub(epubInputStream)
// Log the book's authors
Log.i("epublib","author(s): " + book.metadata.authors)
// Log the book's title
Log.i("epublib","title: " + book.title)
// Log the book's coverimage property
val coverImage = BitmapFactory.decodeStream(
book.coverImage.inputStream
)
Log.i(
"epublib","Coverimage is " + coverImage.width + " by "
+ coverImage.height + " pixels"
)
// Log the tale of contents
logTableOfContents(book.tableOfContents.tocReferences,0)
} catch (e: IOException) {
Log.e("epublib",e.message!!)
}
}
/**
* Recursively Log the Table of Contents
*
* @param tocReferences
* @param depth
*/
private fun logTableOfContents(tocReferences: List<TOCReference>?,depth: Int) {
if (tocReferences == null) {
return
}
for (tocReference in tocReferences) {
val tocString = StringBuilder()
for (i in 0 until depth) {
tocString.append("\t")
}
tocString.append(tocReference.title)
Log.i("epublib",tocString.toString())
logTableOfContents(tocReference.children,depth + 1)
}
}
}
我的webview是我想从资产中读取一个epub文件并在webview中显示
lateinit var webView: WebView
我已插入网站中提供的两个库 进入库 感谢您提前帮助我
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)