如何将向量转换为逗号分隔的字符串
我在 BlackBerry 应用程序中使用向量来保存电子邮件地址,每个地址一个字符串。当我填充 EditField 时,我得到的输出为: [[email protected]< /a>, [email protected]]
我需要输出如:[电子邮件受保护],[电子邮件受保护]
这是因为我需要将这些输出值指定为电子邮件的“收件人”地址。
这里选择的是一个向量。
第一类
obj.call(selected);
这些向量元素分配在第二类中名为 selected2 的另一个向量中
第一类中的第二类调用事件
public static BasicEditField toadd;
public void call(Vector selected2)
{
selected = new Vector();
selected.addElement(selected2);
for(int i=0;i<selected.size();i++)
{
toadd.setText((String) selected.elementAt(i).toString());
}
}
I am using a vector in my BlackBerry app to hold email addresses, one string per address. When I populate an EditField, I get output as : [[email protected], [email protected]]
I need output as : [email protected], [email protected]
This is because I need to assign these output values as a To address for an email.
here selected is one vector.
first class
obj.call(selected);
These vector element assigned in another vector in second class named as selected2
second class call event in first class
public static BasicEditField toadd;
public void call(Vector selected2)
{
selected = new Vector();
selected.addElement(selected2);
for(int i=0;i<selected.size();i++)
{
toadd.setText((String) selected.elementAt(i).toString());
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 call() 方法中,您期望所选向量具有两个元素,而实际上它只有一个元素。 selected 中唯一的元素是向量 selected2。如果要将 selected2 的所有元素分配给 selected ,那么您应该循环 selected2 并将其所有元素放入 selected 中。因此,方法的开头应如下所示:
然后方法的其余部分将正常进行。
In the call() method you are expecting the selected vector to have two elements while in reality it has one. The only element in selected is the vector selected2. If you want to assign all the elements of selected2 to selected then you should loop through selected2 and put all of its elements in selected. So the start of your method should look like this:
And then the rest of the method will proceed normally.