以GOD的名义
您好 我有一个文本文件,想要阅读和显示到textview与不同的字体和颜色的奇数行和偶数行,如何更改此阅读代码:
代码:
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard,"komeil.txt");
StringBuilder text = new StringBuilder();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
text.append('\n');
while ((line = br.readLine()) != null) {
text.append(line);
text.append('\n');
}
}
catch (IOException e) {
//You'll need to add proper error handling here
}
喜欢这个文本文件:
文件:
hello people i am student //black
i want to rad this file //green
different color //black
different font //green
how to do this //black
... //green
... //black
. //green
. //black
. //green
答案 0 :(得分:1)
在textview中无法实现,因为textview只接受一种颜色。为此,你必须使用webview,用不同颜色的线创建html页面