Android里string.xml使用html标签的方法
2013-07-22 15:34
525 查看
Android里string.xml使用html标签的方法
2011年12月21日 ⁄ 编程技术 ⁄
共 1107字
⁄ 暂无评论 ⁄ 被围观 3,656 views+
方法1、使用 CDATA(推荐)
<string name="demoStr"><Data><![CDATA[ <b>ABC</b> ]]> </Data></string>
方法2、转义HTML标签
<string name="myHeadStr"><b><u>bold, underline </u></b></string>
在程序里引用:
Html.fromHtml(getResources().getString(R.string.myHeadStr));
效果图
android string html标签用法
<a href="http://www.chendw.cn/wp-content/uploads/2011/12/20111221160111.png" class="cboxElement" rel="example4" 606"="" style="text-decoration: none; color: rgb(1, 150, 227);">
![](http://www.chendw.cn/wp-content/uploads/2011/12/20111221160111.png)
string.xml代码
Code ViewCopyPrint
<string name="test"><Data><![CDATA[ <b><font color="#ff0000">ABC</font></b> ]]></Data></string>
java代码:
Code ViewCopyPrint
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.Html;
public class testActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AlertDialog.Builder dialog = new AlertDialog.Builder(testActivity.this);
dialog.setTitle("测试HTML标签").setMessage(Html.fromHtml(getString(R.string.test))).setPositiveButton(getString(R.string.btn_confirm), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).create().show();
}
}
2011年12月21日 ⁄ 编程技术 ⁄
共 1107字
⁄ 暂无评论 ⁄ 被围观 3,656 views+
方法1、使用 CDATA(推荐)
<string name="demoStr"><Data><![CDATA[ <b>ABC</b> ]]> </Data></string>
方法2、转义HTML标签
<string name="myHeadStr"><b><u>bold, underline </u></b></string>
在程序里引用:
Html.fromHtml(getResources().getString(R.string.myHeadStr));
效果图
android string html标签用法
<a href="http://www.chendw.cn/wp-content/uploads/2011/12/20111221160111.png" class="cboxElement" rel="example4" 606"="" style="text-decoration: none; color: rgb(1, 150, 227);">
![](http://www.chendw.cn/wp-content/uploads/2011/12/20111221160111.png)
string.xml代码
Code ViewCopyPrint
<string name="test"><Data><![CDATA[ <b><font color="#ff0000">ABC</font></b> ]]></Data></string>
java代码:
Code ViewCopyPrint
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.Html;
public class testActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AlertDialog.Builder dialog = new AlertDialog.Builder(testActivity.this);
dialog.setTitle("测试HTML标签").setMessage(Html.fromHtml(getString(R.string.test))).setPositiveButton(getString(R.string.btn_confirm), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).create().show();
}
}
相关文章推荐
- html 自定义标签使用实现方法
- HTML <fieldset> 标签使用方法
- html中<a>标签的使用方法 设置锚点导航.发邮件.打电话......
- HTML中javascript的<script>标签使用方法详解
- thinkPHP的Html模板标签使用方法
- <html:optionsCollection />标签与LabelValueBean使用方法
- IOS中过滤HTML标签&&WebView的三种常用的使用方法
- 【CVTE】请使用原声Javascript实现一个方法,判断html中出现次数最多的标签,并统计这个次数
- HTML标签<a>的使用方法
- Java使用正则表达式删除所有HTML标签的方法示例
- 使用rails自带方法去除html标签
- iOS中使用正则表达式去掉HTML中的标签元素获得纯文本的方法
- jquery的html()方法,不是输出所有的html标签,比如div标签,明明有,使用html()方法中得到的html代码中,就是没有
- html a标签-超链接中confirm方法使用介绍
- html 自定义标签使用实现方法
- Html Mailto标签详细使用方法
- html各个标签属性及使用方法资料(VIP)
- HTML embed标签使用方法和属性详解
- HTML <fieldset> 标签使用方法
- (HTML控件篇)fieldset和legend标签的属性和使用方法