国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

Android webView如何輸出自定義網(wǎng)頁

瀏覽:6日期:2022-09-22 14:14:03

這次來使用webview輸出網(wǎng)頁型數(shù)據(jù)。因為這樣的數(shù)據(jù)好使用富文本編輯器,有各種各樣的拓展。

上代碼:

package controller.hzl.com.testcall;import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.webkit.WebView;import android.webkit.WebViewClient;import android.widget.Toast;public class MainActivity extends AppCompatActivity { private WebView webView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String webs = ''<!DOCTYPE html>n' +'<html>n' +'<head>n' +'<meta charset='utf-8'>n' +'<title>hello tomcat</title>n' +'</head>n' +'<body>n' +' <h1>1</h1>n' +' <p>2</p>' +'tel:13800138000' +'</body>n' +'</html>'' ; webView = (WebView) findViewById( R.id.webview ); //webview webView.loadDataWithBaseURL( null, webs , 'text/html', 'UTF-8', null ) ; } }

頁面代碼:

<?xml version='1.0' encoding='utf-8'?><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' android:fitsSystemWindows='true' tools:context='.MainActivity'> <WebView android: android:layout_width='match_parent' android:layout_height='match_parent'> </WebView></RelativeLayout>

這里提示一點,如果想要拿網(wǎng)頁進行顯示的話,需要加一行代碼,不然顯示不了。

</application> <uses-permission android:name='android.permission.INTERNET' />

代碼完畢,放結(jié)果:

Android webView如何輸出自定義網(wǎng)頁

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標簽: Android
相關文章:
主站蜘蛛池模板: 安达市| 和政县| 天台县| 疏附县| 子长县| 邹城市| 昔阳县| 榕江县| 大足县| 阳新县| 太湖县| 阿合奇县| 昔阳县| 泽库县| 长沙市| 塔河县| 枝江市| 罗城| 西青区| 兴山县| 仪陇县| 湖南省| 长顺县| 平乐县| 红桥区| 彰化市| 成都市| 盖州市| 射阳县| 腾冲县| 灵川县| 卢龙县| 车致| 康马县| 阜南县| 会理县| 宣恩县| 德阳市| 库车县| 额济纳旗| 五莲县|