读取富文本到TextView中

:1:首先xml布局先布局成scrollView可拖拽

读取富文本到TextView中_第1张图片

2:通过一下方法

读取富文本到TextView中_第2张图片

public String getFromAssets(String fileName) {

String Result = "";

InputStreamReader inputReader = null;

BufferedReader bufReader = null;

try {

inputReader = new InputStreamReader(getResources().getAssets()

.open(fileName));

bufReader = new BufferedReader(inputReader);

String line = "";

while ((line = bufReader.readLine()) != null) {

Result += line;

Result += "\n";

}

return Result;

} catch (Exception e) {

e.printStackTrace();

} finally {

if (bufReader != null && inputReader != null) {

try {

bufReader.close();

inputReader.close();

} catch (IOException e1) {

e1.printStackTrace();

}

}

}

return Result;

}

3:设置调用

你可能感兴趣的:(读取富文本到TextView中)