我想知道什么是最好的方式添加颜色到列表上的每个条目使用simplecursoradapter创建?以下代码使用SimpleCursorAdapter创建了一个列表视图,但文本的颜色都是默认的灰色。我想要做的是根据日期将R.id.rowTitle和R.id.rowName中的文本颜色更改为不同的颜色。添加颜色到简单的光标适配器列表视图
Cursor cursor = database.getTitles();
startManagingCursor(cursor);
String[] columns = { SQLController.TITLE,
SQLController.COLUMN_NAME, SQLController.DATE,
};
int to[] = {R.id.rowTitle, R.id.rowName,R.id.rowDate};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.rows, cursor, columns, to);
this.setListAdapter(adapter);
UFF所以你应该创建类,将''从SimpleCursorAdapter' extends',然后创建设计模式'Holder'守住你的每一行,最后在'getView()'方法''从'SimpleCursorAdapter'手动扩展的CursorAdapterClass会根据需要设置颜色。我可以在这里添加我的代码,但它有更多的线条。 – Sajmon