开发者

Write a paragraph using textview on Android

I want to write a paragraph 开发者_JS百科as part of my mobile application. How do I go about it?


Use \n to break line.

Example:

TextView t = findViewById(R.id.text);
t.setText("This is the first line\nThis is the second line\nThird line...");


<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="text_with_paragraphs">
        Can this contain a lot of text? Can it contain \n a newline? Yes, it can.
        Adding a 2nd line like this should work.
        It should not cause parsing errors.
    </string>
<resources>

So you can make a reference to it like:

android:text="@string/text_with_paragraphs"

Reference: http://www.experts-exchange.com/Programming/Smartphones/Android/Q_27925834.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜