我在资产文件夹中使用数据存储,如“reader.txt”,此数据使用“InputStream”获取字符串值,如在 textview 中设置为字符串值。我的问题是如何在列表视图中存储字符串?
这是我的代码:
try {
InputStream is = getAssets().open("reader.txt");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
// Convert the buffer into a string.
String text = new String(buffer);
TextView tv = (TextView) findViewById(R.id.list);
tv.setText(text);
} catch (IOException e) {
// Should never happen!
throw new RuntimeException(e);
}