發現mini飛信的使用幫助和更新日誌使用的是一個Dialog中顯示html文件中的內容,而且QQ的關於也是使用的HTML文件
自己也想實現類似效果
然後google:
http://stackoverflow.com/questions/1955043/android-html-container
EboMike提供的方法,這個只是使用Html代碼,並不是把一個html文件當做資源來引用:
.setMessage(Html.fromHtml("<b>Bold text</b> <i>and italics</i>"))
發現Html文件需要放在assets文件夾下,查了下assets文件夾的用途找到這兩篇:
http://www.cnblogs.com/stay/articles/1898965.html (Android讀取assets目錄下的資源)
http://blog.csdn.net/gsg8709/article/details/7326745 (android 文件讀取(assets))
原來應該這麼用:
WebView.loadUrl(“file:///android_asset/sample.html”);
然後,Android 開發文檔:WebView
http://developer.android.com/reference/android/webkit/WebView.html
然後,參考了這篇博文:android中使用html作佈局文件,非常感謝dinglang_2009,給了很大啓發
http://blog.csdn.net/dinglang_2009/article/details/6862627
其實,在http://stackoverflow.com/questions/1955043/android-html-container
JRL已經給瞭解決方案,只是自己沒有注意到:
"Not sure what you're trying to do, but
WebView
handles HTML."
又仔細看了下,使用webview來加載htnl文件其實是有延遲的,我就用它來顯示使用幫助和更新日誌這類東西的,效果很好。
最後就是實現了,要自定義Dialog,兩篇很好的參考文章:
http://griffinshi.iteye.com/blog/568409
http://www.oschina.net/question/12_35723
使用百度,輸入android dialog html 會得到這樣一篇文章
http://shareandopen.tumblr.com/post/12598945632/open-local-html-file-in-custom-dialog
Done!
Enjoy~