2017-04-14 166 views
-2

当我在textview中执行setText时,它只显示数组的前三行,我需要一种方法来做result = result + xx.split(“\ n”);但在字符串数组中,这是不可能的,你可以教我另外一种方式来做到这一点吗?如何遍历字符串数组?

String xx=""; 
String result[] = {}; 

for(int i=0;i<row;i++) { 
    for(int c=0;c<col;c++) { 
     Cell z=s.getCell(c,i); 
     //Need an alternative to this because cannot do this in string array 
     result = result+ xx.split("\n"); 
    } 
}  
textview.setText(resultado[0]+"--"+resultado[1]+"--"+resultado[2]); 
+0

'String xx'是空的吗?此外,遍历'result',将值添加到问题的'textView'中,而不是'result + =“something”;' –

+0

为什么不将'split'存储在一个数组中,然后通过它进行交互? – Compass

+0

字符串xx不是空的。你可以在下面举个例子吗? – jose

回答

0

您需要更具体地了解您正在尝试实现的目标,但这是对数组的基本迭代。

String numbers = new String[] {"1", "2", "3", "4", "5"}; 
String myString = ""; 

for (String aNumber : numbers) { 
    myString += aNumber; 
} 

textview.setText(myString); 
+0

我需要在varibales中存储位置以便将它们保存在sqlite中 – jose