How to show web page in my app?

后端 未结 2 1850
自闭症患者
自闭症患者 2021-02-07 21:07

I need to send from server side simple web pages (with images) some how (mht, or zipped web page folders) and show it on UI of my Android application without browser control, ca

2条回答
  •  余生分开走
    2021-02-07 21:55

    To show a web page in your app, there are two ways to do it: use the default Browser of Android, or use a WebView. For the second one, you can do this:

    WebView webView = (WebView)findViewById(R.id.webView);
    //you can load an html code 
    webView.loadData("yourCode Html to load on the webView " , "text/html" , "utf-8");
    // you can load an URL 
    webView.loadUrl("http://www.stackoverflow.com");
    

    layout XML :

    In your layout Xml, define an WebView like this:

    
    

提交回复
热议问题