-5

可能重复:
如何在 EditText 中创建多行字符串?

我想在多行 EditText 中显示一个字符串。目前,字符串显示为....

Receive: 0 coin(s) Total
             Cost: $100

我希望它显示为...

Receive: 0 coin(s) 
Total Cost: $10

这是我的代码,我尝试使用“\n”,但无济于事......

result.setText("Receive:"+ " "+ df.format(rawounces)+"coin(s)" + "\n" 
     + "Total Cost:$" + df.format(transactionandpremium*rawounces));

先感谢您。

4

1 回答 1

0

您可以使用 Html 属性根据需要将文本设置为 ::

<EditText
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   />

String str="Receive: 0 coin(s) <br> Total Cost: $10";
editText.setText(Html.formHtml(str));  
于 2012-07-25T04:29:58.527 回答