webView 显示一段 html 代码
2024-08-24 11:26:40
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='width:45px;'>" +
"起 息 日:</td><td>当日22:00前投资," +
"当日计息</td></tr><tr><td>还 款 日:</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、显示效果
最新文章
- 熟悉HTML CSS布局模型
- ASP.NET Core (Database First)
- windows 下 gvim打开默认全屏显示
- tc 146 2 RectangularGrid(数学推导)
- IOS 蓝牙相关-BabyBluetooth蓝牙库介绍(4)
- Linq ExecuteQuery,ExecuteCommand
- 机器人学 —— 机器人感知(Kalman Filter)
- C# 将字符串转化成流,将流转换成字符串
- SAP-设置显示表格格式
- hdu 2012 素数判定 Miller_Rabbin
- SQL入门学习4-复杂查询
- 51 Nod 1119
- [ffmpeg] AVOption
- for in 循环 和for循环 for of循环
- advancedsearch.php织梦高级自定义模型字段无法调用解决方案
- 使用SpringBoot Admin监控SpringCloud微服务
- HDU 6300
- 九浅一深ThreadLocal
- Java 集合系列Stack详细介绍(源码解析)和使用示例
- JAVA-JSP内置对象之request获得所有的参数名称
热门文章
- jQuery 3.1 API中文文档
- 【分享】学长的安利来了~~O(∩_∩)O
- 【Android学习笔记】XmlResourceParser解析xml文件
- JS 实现可停顿的垂直滚动
- Spring @Transactional propagation 各个属性值的含义
- Android对话框自定义标题
- 蘑菇街2015校招 Java研发笔试题 详解
- ViewPager的刷新、限制预加载、缓存所有
- android 歌词解析
- IO流(一)__File对象和字符流FileWriter FileReader