更改的TextView的颜色 [英] Changing color of TextView
本文介绍了更改的TextView的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想换一个的TextView
我的活动里面
取值的ListView的颜色
在Java code。 的ListView
包含由 MatrixCursor
和 ArrayAdapter $ C $喂多行C>。在
的TextView
的颜色应该是绿色或应该由如果
子句来确定白色。我怎样才能做到这一点?
CITEM = NameManager.getciList();
NameManager.WriteName(CITEM);
MatrixCursor光标;
光标= NameManager.getnameList();
startManagingCursor(光标);
如果(cursor.getString(9).equals(是)){
R.id.name颜色// TODO设置的颜色在这里
}
的String [] =从{姓名,信息,状态,路径,文件夹,BaseColumns._ID};
INT []为= {R.id.name,R.id.info,R.id.status,R.id.path};
最后SimpleCursorAdapter适配器=新SimpleCursorAdapter(这一点,
R.layout.row,光标,从,到);
setListAdapter(适配器);
解决方案
编写自定义的适配器,在这里你可以设置颜色,列表的大小items.see这
链接它会让你知道的想法。
下面是蓝色的文本颜色LIS
I want to change the color of a TextView
inside my Activity
s ListView
by java code. ListView
contains multiple rows which are fed by a MatrixCursor
and an ArrayAdapter
. The color of the TextView
should be green or white which should be determined by an if
clause. How can I accomplish this?
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);
解决方案
write your own custom adapter, where you can set color, size of list items.see this link it will let u know an idea. below is lis with blue text color
这篇关于更改的TextView的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文