这是我的java代码,在这里我必须在字符串数组项类型中添加一个字符串“RFID”,并且我必须将其存储在另一个字符串数组项中。但是我收到错误。
String[] itemtype;
String[] item;
\...........
.........../
try {
response = (SoapPrimitive) envelope.getResponse();
Koradcnos = response.toString();
} catch (SoapFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
itemtypes = Koradcnos.split(";");
item=itemtypes+"RFID";//here im getting error
} catch (Exception er) {
//Helper.warning("Error", er.toString(),this);
}
imageId = new int[itemtypes.length];
for (int i = 0; i < itemtypes.length; i++)
if (itemtypes[i].equals("Yarn")) {
imageId[i] = R.drawable.yarnitem;
最佳答案
您需要解决这个问题:
与Arrays.copyOf
一起使用
item = Arrays.copyOf(itemtypes , itemtypes.length + 1);
item[item.length - 1] = "RFID";
或者直接从Koradcnos
拆分
item = (Koradcnos + ";RFID").split(";");
关于java - 如何在android中将一个字符串添加到另一个字符串数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35014537/