Android編程實現(xiàn)使用webView打開本地html文件的方法
本文實例講述了Android編程實現(xiàn)使用webView打開本地html文件的方法。分享給大家供大家參考,具體如下:
在布局的配置文件里:
<WebView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/webView"> </WebView>
后臺java代碼;
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webView);
//設(shè)置WebView屬性,能夠執(zhí)行Javascript腳本
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDefaultTextEncodingName("utf-8");
//即asserts文件夾下有一個a.html
webView.loadUrl("file:///android_asset/a.html");
}
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android視圖View技巧總結(jié)》、《Android開發(fā)動畫技巧匯總》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android布局layout技巧總結(jié)》、《Android開發(fā)入門與進(jìn)階教程》、《Android資源操作技巧匯總》及《Android控件用法總結(jié)》
希望本文所述對大家Android程序設(shè)計有所幫助。
- Android中Webview打開網(wǎng)頁的同時發(fā)送HTTP頭信息方法
- Unity3D游戲引擎實現(xiàn)在Android中打開WebView的實例
- Android使用WebView.loadUri()打開網(wǎng)頁的方法
- Android webview打開本地圖片上傳實現(xiàn)代碼
- Android中Textview超鏈接實現(xiàn)方式
- Android實現(xiàn)捕獲TextView超鏈接的方法
- android:TextView簡單設(shè)置文本樣式和超鏈接的方法
- Android使用TextView實現(xiàn)無下劃線超鏈接的方法
- Android TextView添加超鏈接的方法示例
- Android使用內(nèi)置WebView打開TextView超鏈接的實現(xiàn)方法
相關(guān)文章
android開發(fā)教程之textview內(nèi)容超出屏幕寬度顯示省略號
android開發(fā)中用textview顯示內(nèi)容時,顯示內(nèi)容過多可能會折行或顯示不全,那樣效果很不好,我們可以用省略號顯示,下面看設(shè)置方法2014-02-02
Android使用百度地圖出現(xiàn)閃退及定位時顯示藍(lán)屏問題的解決方法
這篇文章主要介紹了Android使用百度地圖出現(xiàn)閃退及定位時顯示藍(lán)屏問題的解決方法,需要的朋友可以參考下2018-01-01

