Blogger Scott

解决TextView行尾小方格问题

Android中,有时用TextView打开UTF-8文本文件,在每行的末尾会出现一个小方格,这主要是由于换行符"r"造成的。
解决方法很简单,用空格代替"r"即可,即string = string.replace("\r", ""),代码段如下:

baos是ByteArrayOutputStream类,用来读文本文件的。

  

1                    CharSequence tempStr;
2                    tempStr = new String(baos.toString().replace("\r"""));
3                    TextView m_TextView = new TextView(this);
4                    m_TextView.setBackgroundColor(Color.BLACK);
5                    m_TextView.setText(tempStr);

posted on 2010-02-19 13:25 江天部落格 阅读(449) 评论(0)  编辑  收藏 所属分类: Android


只有注册用户登录后才能发表评论。


网站导航: