Android webView如何輸出自定義網(wǎng)頁(yè)
這次來(lái)使用webview輸出網(wǎng)頁(yè)型數(shù)據(jù)。因?yàn)檫@樣的數(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 ) ; } }
頁(yè)面代碼:
<?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:id="@+id/webview" android:layout_width="match_parent" android:layout_height="match_parent"> </WebView> </RelativeLayout>
這里提示一點(diǎn),如果想要拿網(wǎng)頁(yè)進(jìn)行顯示的話,需要加一行代碼,不然顯示不了。
</application> <uses-permission android:name="android.permission.INTERNET" />
代碼完畢,放結(jié)果:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Android使用SharedPreferences存儲(chǔ)數(shù)據(jù)的實(shí)現(xiàn)方法
這篇文章主要介紹了Android使用SharedPreferences存儲(chǔ)數(shù)據(jù)的實(shí)現(xiàn)方法,可實(shí)現(xiàn)針對(duì)短信的臨時(shí)保存功能,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下2016-06-06Android實(shí)現(xiàn)原生鎖屏頁(yè)面音樂(lè)控制
這篇文章主要介紹了Android實(shí)現(xiàn)原生鎖屏頁(yè)面音樂(lè)控制,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-12-12淺談Android onTouchEvent 與 onInterceptTouchEvent的區(qū)別詳解
本篇文章小編為大家介紹,Android onTouchEvent 與 onInterceptTouchEvent的區(qū)別詳解。需要的朋友參考下2013-04-04Android實(shí)現(xiàn)單項(xiàng)、多項(xiàng)選擇操作
這篇文章主要介紹了Android實(shí)現(xiàn)單項(xiàng)、多項(xiàng)選擇操作的相關(guān)資料,單項(xiàng)選擇、多項(xiàng)選擇操作在項(xiàng)目開(kāi)發(fā)中經(jīng)常應(yīng)用,感興趣的小伙伴們可以參考一下2016-04-04cocos2d-2.0-x-2.0.3 交叉編譯到android報(bào)錯(cuò)解決
我用的是cocos2d-2.0-x-2.0.3 之前弄了一天也沒(méi)成功 今天來(lái)了下載了最新的ndk8 更新了sdk 又重新是了一遍 居然成功了,不知道是工具的版本問(wèn)題還是哪一步出錯(cuò)誤了,在這里詳細(xì)的整理一下,感興趣的朋友可以了解下2013-01-01Flutter利用Hero組件實(shí)現(xiàn)自定義路徑效果的動(dòng)畫
本篇介紹了如何利用Hero動(dòng)畫組件的createRectTween屬性實(shí)現(xiàn)自定義路徑效果的動(dòng)畫。文中的示例代碼講解詳細(xì),感興趣的可以了解一下2022-06-06OpenGL Shader實(shí)現(xiàn)光照發(fā)光體特效
這篇文章主要介紹了如何通過(guò)OpenGL Shader實(shí)現(xiàn)光照發(fā)光體特效,不同于陰影遮蓋,它是利用圓形繪制向內(nèi)部。感興趣的小伙伴可以了解一下2022-02-02