我有问题,我从一项活动中获取我的数据。我想使用列表视图打印它。我该怎么做。?
Intent intent = getIntent();
ArrayList<String> fruitSelection = intent.getStringArrayListExtra("fruits");
if (fruitSelection != null) {
// use a toast to display selected fruits
if (fruitSelection.size() > 0) {
StringBuilder sb = new StringBuilder();
sb.append("Your selection of fruits\n\n");
for (String s : fruitSelection) {
sb.append("* ").append(s).append("\n");
}
Toast toast = Toast.makeText(this, sb.toString().trim(), Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
} else {
Toast toast = Toast.makeText(this, "Nothing selected", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();}
}
}
}