【问题标题】:changing font colour in ListView, database, android更改 ListView、数据库、android 中的字体颜色
【发布时间】:2013-01-09 20:05:01
【问题描述】:

我正在使用这个android list view tutorial (它显示了如何在列表视图中显示数据库条目),我正在考虑更改数据库条目的颜色,是否可以更改每一行的颜色?例如德国将是红色,西班牙是黄色等,颜色将取决于字符串?

  // map each name to a TextView
        String[] from = new String[] { "countryname" };
        int[] to = new int[] { R.id.countryTextView };


 conAdapter = new SimpleCursorAdapter(Countrylist.this, R.layout.country_view, null, from, to);
        setListAdapter(conAdapter); // set adapter

【问题讨论】:

    标签: android listview colors


    【解决方案1】:

    可以通过自定义适配器来实现,

    在自定义适配器getView方法中,可以根据自己的情况设置textView的背景

    请查找参考资料,

    http://android.cyrilmottier.com/?p=454

    【讨论】:

    • 谢谢!这个教程看起来很棒:)
    猜你喜欢
    • 2013-09-24
    • 1970-01-01
    • 2011-10-31
    • 2017-01-27
    • 1970-01-01
    • 1970-01-01
    • 2015-04-16
    • 2014-05-05
    • 1970-01-01
    相关资源
    最近更新 更多