如何在Android的打印nextline数组元素上的TextView [英] how to print array elements in nextline on textView in android
本文介绍了如何在Android的打印nextline数组元素上的TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我有一个二维数组。我打印这个阵列上的文本视图的元素。但我的所有元素来了一个row.I想要元素之间换行。我的code在下面给出我的二维数组是:
hello everyone i have a 2D array. I am printing the elements of this array on a text View. But my all elements are coming in one row.I want line break between elements. my code is given below and my 2D array is:
table[][]={{1,2,3,4,5,6,7,8},{8,7,6,5,4,3,2,1}}
for(i=0;i<8;i++)
for(j=0;j<2;j++)
{
text = new TextView(this);
text.setText(""+table[j][i]);
}
像这样的
和我得到的输出:
and i am getting output like this:
{1,8,2,7,3,6,4,5,5,4,6,3,7,2,8,1}
但我想这样的输出:
but i want output like this:
1,8
2,7
3,6
4,5
5,4
6,3
7,2
8,1
任何帮助将是AP preciated。
any help would be appreciated.
推荐答案
我会建议不要在回路中产生的TextView。 只要使用相同的看法:
I would suggest not to create TextView in the loop. Just use same view:
table[][]={{1,2,3,4,5,6,7,8},{8,7,6,5,4,3,2,1}}
text = new TextView(this);
for(i=0;i<8;i++) {
for(j=0;j<2;j++) {
text.append(""+table[j][i] + "\n");
}
}
这篇关于如何在Android的打印nextline数组元素上的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文