Android如何在文本视图或任何东西打印数组 [英] Android how to print a array in text view or anything

查看:154
本文介绍了Android如何在文本视图或任何东西打印数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些单词,我想在单击按钮后在文本视图中将单词数组打印到屏幕上。我正在使用循环遍历整个列表,然后设置文本,但我一直得到一个错误,加上它只会取代最后一个值,所以它不会打印整个数组。如果有人可以向我解释如何做像g.drawSting(),但Android版本,这将是伟大的。我的代码rt现在不在我身边,但它是这样的:
- 我是一个初学者Android机器人顺便说一句,可能可以告诉这个问题,这一点。

<$ p

//代码只是按下一个按钮{
//去两个方法来修复私有数组$ {code $> public void onCreate(Bundle savedInstanceState)
{
for(int y = 0; y< = array.size() - 1; y ++){
textArea.setText(aarray.get(y)); //打印数组
}
}
}


解决方案

  int arraySize = myArray.size(); 
for(int i = 0; i< arraySize; i ++){
myTextView.append(myArray [i]);





$ b如果你想逐一打印,那么使用\ n p>

  myTextView.append(myArray [i]); 
myTextView.append(\\\
);


I have a array of words and I would like to print the array of words onto the screen in a text view after a button is clicked. i was using a for loop to go through the whole list and then set text, but i keep getting a error with that plus it will just replace the last value, so it wont print the whole array. If anybody could explain to me how to do like a g.drawSting() but android version that would be great. my code rt now is not with me but it something like: -I'm a beginner to android btw, probably could tell by this question tho.

public void onCreate(Bundle savedInstanceState)
{
//code for a button just being pressed{
 //goes to two methods to fix the private array{
     for(int y=0; y<=array.size()-1; y++){
        textArea.setText(aarray.get(y));   //prints all strings in the array
 }
}
}

解决方案

int arraySize = myArray.size();
for(int i = 0; i < arraySize; i++) {
myTextView.append(myArray[i]);
}

if you want to print one by one, then use \n

myTextView.append(myArray[i]);
myTextView.append("\n");

这篇关于Android如何在文本视图或任何东西打印数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆