Android:每行都有一堆短文;文字管理

时间:2013-04-03 07:47:44

标签: android text textview

我有很多简短的文字放在他们自己的行中,以便在Android的TextView中显示。

像这样:

姓名:Smoe

年龄:100

年份:1099

等等

我现在在50行以上的简单文本编辑器中使用它。

我的问题:我如何管理它以进行有效编码和显示?我应该做很多手工劳动并在每个人手册上添加“\ r \ n”并放入Strings.xml吗?

或者有没有办法可以将它放在txt文件中以便有效加载代码?

Pls提供煽动,我提前感谢你的帮助,请原谅我在Android JAVA中最环保的东西。 :)

2 个答案:

答案 0 :(得分:0)

然后尝试使用表格。类似的东西:

<TableView>
    <TableRow>
        <TextView> <!-- to display the label -->
        <TextView> <!-- to display the value -->
    </TableRow>
    <TableRow>
        <TextView> <!-- to display the label -->
        <TextView> <!-- to display the value -->
    </TableRow>
    <TableRow>
        <TextView> <!-- to display the label -->
        <TextView> <!-- to display the value -->
    </TableRow>
    .
    .
    .
<TableView>

可以动态创建这些表格并将其添加到tableView中。

答案 1 :(得分:0)

如果您只想加载静态文本,可以将文件放在assets目录中。然后您不必担心添加手动换行符。

以这种方式获取资产的输入流:

is = mContext.getAssets().open("myfile.txt");