Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 我想以字符串数组的形式发送结果_Android_Arrays - Fatal编程技术网

Android 我想以字符串数组的形式发送结果

Android 我想以字符串数组的形式发送结果,android,arrays,Android,Arrays,我希望以字符串数组而不是文本形式发送结果。以下是以文本形式发送结果的代码。但我希望以字符串数组形式发送结果 ChannelSftp sftpChannel = (ChannelSftp) channel; try { Vector ls=sftpChannel.ls("/home/abc/Desktop"); for(int i = 0; i < ls.size(); i++) { text += sftpChannel.pwd() + "/" + ((

我希望以字符串数组而不是文本形式发送结果。以下是以文本形式发送结果的代码。但我希望以字符串数组形式发送结果

ChannelSftp sftpChannel = (ChannelSftp) channel;

try {
    Vector ls=sftpChannel.ls("/home/abc/Desktop");

    for(int i = 0; i < ls.size(); i++) {
        text += sftpChannel.pwd() + "/" + (((LsEntry)ls.get(i)).getFilename()) + "\n";
    }

    t.post(new Runnable() {
        public void run() { t.setText(text); }
    });

    } catch (SftpException e1) { }
ChannelSftp sftpChannel=(ChannelSftp)信道;
试一试{
向量ls=sftpChannel.ls(“/home/abc/Desktop”);
对于(int i=0;i
ChannelSftp sftpChannel=(ChannelSftp)信道;
试一试{
向量ls=sftpChannel.ls(“/home/abc/Desktop”);
字符串[]字符串=新字符串[ls.size];
对于(int i=0;i
您到底想发送什么?当前您正在设置元素t的文本(我猜是文本视图)。此方法将不接受数组。您可以将文本中的值保存为数组,而不是串联字符串。这就是你想要的吗?
ChannelSftp sftpChannel = (ChannelSftp) channel;

try {
    Vector ls=sftpChannel.ls("/home/abc/Desktop");
    String[] strings = new String[ls.size];

    for(int i = 0; i < ls.size(); i++) {
        strings[i] = sftpChannel.pwd() + "/" + (((LsEntry)ls.get(i)).getFilename());
    }

    t.post(new Runnable() {
        public void run() { t.setText(strings.toString()); }
    });

    } catch (SftpException e1) { }