-1

如何获取这样的数组项

[“字符串 1”、“字符串 2”、“字符串 3”、.....、“字符串”]

但是如果我们使用 Arrays.toString(array) 它将显示为 [string1, string2, string3] 但我想要像上面那样。

提前感谢

4

1 回答 1

1

This is how I did it:

private void btn3() {
    LinearLayout layout = (LinearLayout) findViewById(R.id.ll);
    layout.removeAllViewsInLayout();
    layout.setPadding(15, 15, 15, 15);

    tv2 = new TextView[list.size()];
    for (int i = 0; i < list.size(); i++) {
        tv2[i] = (TextView) new TextView(Random.this);
    }

    LayoutParams lparams = new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    for (int i = 0; i < list.size(); i++) {
        tv2[i].setLayoutParams(lparams);
        tv2[i].setText((i + 1) + " " + list.get(i));
        layout.addView(tv2[i]);
    }
}
于 2013-09-20T14:58:39.513 回答