经过一番谷歌搜索但没有运气后,我再次来到这里打扰你们:)
我的应用程序中有 ListView,它是通过 SQLitle 数据库从游标填充的。看起来像这样:
public void updateShiftList(String x) {
db.openToRead();
listShifts = (ListView) findViewById(R.id.listShifts);
// get data
cursor = db.getPlan(x);
startManagingCursor(cursor);
// set adapter
String[] from = { dataManager.KEY_SHIFT, dataManager.KEY_DATE };
int[] to = { R.id.rowShift, R.id.rowDate };
adapter = new SimpleCursorAdapter(this, R.layout.row, cursor, from, to);
listShifts.setAdapter(adapter);
db.close();
}
在 row.xml 中,每行之前都有图像,我想在创建此 ListView 期间实现函数或检查方法,这将根据我要测试的一些参数更改图像,例如 R.id.rowDate == TodayDate(该文本字段中有日期)或者 R.id.rowDate 是否是今天的下一个日期......
我怎样才能做到这一点,或者在哪里......有一些可以使用的 Overide 吗?我正在这个简单的项目上学习java,所以要温柔:)
谢谢大家, 弗拉德
最佳答案
再一次...
构建一个使用您的数据的自定义适配器...
Whenever you want to do processing with the views in a ListView you need to create a custom adapter that will handle your logic implementation and pass that information to the views as necessary.
示例
关于java - 安卓 Java : changing image in listview depending on content,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9148412/