繁体   English   中英

更改TextView的颜色

[英]Changing color of TextView

我想通过Java代码在ActivityListView内更改TextView的颜色。 ListView包含由MatrixCursorArrayAdapter馈送的多行。 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

[R

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM