android中的格式化字符串

在strings.xml文件中定义:

<string name="welcome_messages">你好, %1$s! 是第 %2$d 个人.</string>

在java文件中这么写

  TextView textView = (TextView) findViewById(R.id.t);
  textView.setText(String.format(getResources().getString(R.string.welcome_messages),"heji",1));

<string name="welcome">Welcome to <u><i>Android</i></u>!</string>
<u></u>有下划线
<i></i>斜体字
<b></b>加粗


<string name="tagged_string">
    Hello <b><i>heji</i></b>, loverui.
    </string>

Html.fromHtml(getResources().getString(R.string.tagged_string))



android中的格式化字符串

android中的格式化字符串







你可能感兴趣的:(java,html,android,xml)