1
setContentView
( R .layout . main );
WebView view = new WebView ( this );
view . setVerticalScrollBarEnabled ( false );
((
LinearLayout
) findViewById ( R . id . inset_web_view )). addView ( view );
view . loadData ( getString ( R . string . hello ), "text/html" , "utf-8" );
<string
name = "hello" >
<![CDATA[
<html> <head></head>
<body style = " text - align : justify ; color : gray ; background - color : black ; " >
Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Nunc pellentesque, urna
nec hendrerit pellentesque, risus mass
</body>
</html> ]]> </string>
2:
Spanned
content
=
Html
.
fromHtml
(
"<div style=\"text-align:justify\">"
+
bundle
.getString
(
CONTENT
)
+
"<\\div>"
);
TextView
txtContent
=
(
TextView
)
findViewById
(
R
.
id
.
txtNewsDetail
);
txtContent
.
setText
(
content
.
toString
(),
BufferType
.
SPANNABLE
);
本文介绍了一个简单的 Android 应用示例,展示了如何使用 WebView 控件加载 HTML 内容,并通过 Spanned 展示富文本。该应用实现了 WebView 的基本配置及 HTML 内容的加载显示。
9708

被折叠的 条评论
为什么被折叠?



