[英]Changing color of TextView
我想通过Java代码在Activity
的ListView
内更改TextView
的颜色。 ListView
包含由MatrixCursor
和ArrayAdapter
馈送的多行。 TextView
的颜色应为绿色或白色,应由if
子句确定。 我该怎么做?
citem = NameManager.getciList();
NameManager.WriteName(citem);
MatrixCursor cursor;
cursor = NameManager.getnameList();
startManagingCursor(cursor);
if (cursor.getString(9).equals("yes")){
//TODO set color of R.id.name color here
}
String[] from = { "name", "info", "status", "path", "folder", BaseColumns._ID };
int[] to = { R.id.name, R.id.info, R.id.status, R.id.path };
final SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.row, cursor, from, to);
setListAdapter(adapter);
编写自己的自定义适配器,您可以在其中设置列表项的颜色,大小。查看此链接,它将使您知道一个想法。 下面是带有蓝色文本颜色的lis
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.