sqlite count行,字符串等于

时间:2013-12-24 14:10:50

标签: android sqlite

我的数据库包含列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;

          }

0 个答案:

没有答案