我的数据库包含列VNP,其中包含文字" G"," Y"或" R"。 使用此适配器,我正确设置了背景颜色,但它不会计算具有相同字母的行
......
vnp = (TextView) findViewById(R.id.vnp);
....
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
if (view.getId() == R.id.semaphore)
{
String VNP = cursor.getString(columnIndex);
if(VNP.equals("G"))
{view.setBackgroundColor(Color.GREEN);
green=green+1;}
if(VNP.equals("Y"))
{view.setBackgroundColor(Color.YELLOW);
yellow=yellow+1;}
if(VNP.equals("R"))
{view.setBackgroundColor(Color.RED);
red=red+1;}
vnp.setText("G: " +String.valueOf(green)+ "- Y: " +yellow+ " - R: " +red);
return true;
}