我正在尝试将此ArrayList
转换为String
,但不希望数字之间有空格。这就是我到目前为止所做的:
ArrayList<String> arrayList = new ArrayList<String>();
String NumberRightString = "";
String ButtonText = "";
public void OnClick (View v) {
Button button = (Button) v;
String ButtonText = button.getText().toString();
arrayList.add(ButtonText);
StringBuilder sb = new StringBuilder();
for (Object obj : arrayList) {
sb.append(obj.toString());
sb.append("\t");
}
String NumString = sb.toString();
NumString.replaceAll("//s","");
textView.setText(NumString + "/" + number);
}
这不起作用,空间仍在那里。请帮帮我!
答案 0 :(得分:3)
尝试替换
NumString.replaceAll("//s","");
到
NumString = NumString.replaceAll("\\s","");