我设置以下字符串作为我txtMessage一个输入:如何在TextView中添加换行符和空格?
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.breaknotification);
TextView txtMessage = (TextView)findViewById(R.id.txtMessage);
String msg = "TIME RECORD VALUE\n" +
"10 AM 1 20\n"+
"11 AM 2 30\n"+
"12 PM 3 40";
txtMessage.setText(msg);
}
我breaknotification.xml文件是按下列内容:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text=""
android:textColor="#FFFFFF"
android:textSize="21sp"
android:textStyle="bold" />
</LinearLayout>
,我想打印我的字符串按以下格式。
TIME RECORD VALUE
10 AM 1 20
11 AM 2 30
12 PM 3 40
但它没有显示出我想要的东西;它显示我以下在我的消息,
TIME RECORD VALUE
`10 AM 1 20`
`11 AM 2 30`
`12 PM 3 40`
那么我怎么能实现它?
你清理和生成项目?我很确定你在做什么是对的,我也会这样做。 – noob 2012-03-10 20:41:45
是的,我清理,但没有工作。 – askimp 2012-03-12 07:45:11