zoukankan      html  css  js  c++  java
  • webView 显示一段 html 代码

    1、布局文件

    <?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>

    2、代码

    package com.webview.demo;
    
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.webkit.WebView;
    
    public class MainActivity extends AppCompatActivity {
    
        private WebView webView ;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            String webs = ""<table style='font-size:12px;'><tr><td style='45px;'>" +
                    "起&nbsp;&nbsp;&nbsp;&nbsp;日:</td><td>当日22:00前投资," +
                    "当日计息</td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;日:</td><td>每日7点</td></tr><tr><td>还款方式:" +
                    "</td><td>按日付息</td></tr></table>"" ;
    
            webView = (WebView) findViewById( R.id.webview );
    
            //webview
            webView.loadDataWithBaseURL( null, webs , "text/html", "UTF-8", null ) ;
    
        }
    }

    3、显示效果

  • 相关阅读:
    JS 数组去重复值
    git 上传项目 到github
    IntelliJ IDEA 创建maven 项目 并且,将springMVC 与Mybatis 整合
    easyui datagrid 动态添加columns属性
    codeMirror的简单使用,js比较文本差异(标注出增删改)
    sql注入
    Web For Pentester靶场
    一些数据库
    nginx的使用场景
    dockerfile
  • 原文地址:https://www.cnblogs.com/zhaoyanjun/p/4977895.html
Copyright © 2011-2022 走看看