简体   繁体   中英

Changing color of TextView

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

[R

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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