小编blu*_*wel的帖子

使用SimpleCursorAdapter.ViewBinder更改TextView的颜色

我正在为Android开发一个闹钟应用程序,我希望在主屏幕上显示警报列表.其中的每一行都ListView在xml文件中定义.我希望TextViews每周的每一天都能分开.程序将检查sqlite db是否为例如.mondayis = 1的值,然后将其颜色更改TextView为红色.我写了这段代码,但这不起作用.怎么了?

private void fillData() {

    // Get all of the notes from the database and create the item list
    Cursor c = db.fetchAllAlarms();
    startManagingCursor(c);

    String[] from = new String[] { db.KEY_TIME, db.KEY_NAME };
    int[] to = new int[] { R.id.time, R.id.alarmName };

    // Now create an array adapter and set it to display using our row
    SimpleCursorAdapter alarms =
        new SimpleCursorAdapter(this, R.layout.alarm_row, c, from, to);
        alarms.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
        public …
Run Code Online (Sandbox Code Playgroud)

sqlite android simplecursoradapter android-cursor android-viewbinder

3
推荐指数
1
解决办法
9079
查看次数