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) { }