更改的TextView的颜色 [英] Changing color of TextView

查看:196
本文介绍了更改的TextView的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想换一个的TextView 我的活动里面取值的ListView的颜色在Java code。 的ListView 包含由 MatrixCursor ArrayAdapter 。在的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 Activitys 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆