2013-01-11 2 views
1

데이터베이스의 항목을 표시하는 목록보기에서 텍스트 색을 변경하려고합니다. 문제는 보이지 않는 텍스트를 표시한다는 것입니다 (또는이 목록에서 내 항목을 분리하는 행만 표시). 항목을 클릭하면이 항목의 세부 정보가 표시됩니다. 표시는 ViewBinder를 사용하지 않고 잘 작동합니다.데이터베이스의 항목을 표시하는 목록보기에서 보이지 않는 텍스트 색

// map each name to a TextView 
    String[] from = new String[] { "event" }; 
    int[] to = new int[] { R.id.countryTextView }; 
    conAdapter = new SimpleCursorAdapter(Clock.this, R.layout.day_plan, null, from, to); 



    SimpleCursorAdapter.ViewBinder binder = new SimpleCursorAdapter.ViewBinder() { 

     @Override 
     public boolean setViewValue(View view, Cursor cursor, int columnIndex){  
      int getIndex = cursor.getColumnIndex("colour"); 
      String empname = cursor.getString(getIndex); 
      tv = (TextView)findViewById(R.id.countryTextView); 

      tv.setTextColor(Color.WHITE); 

      if(empname.equals("Green")) 
      {     
       tv.setTextColor(Color.WHITE); 
       return true; 
      } 
      return false;   
     } 


    }; 
    setListAdapter(conAdapter); // set adapter 
    ((SimpleCursorAdapter) conAdapter).setViewBinder(binder); 

어떻게 작동하도록 변경할 수 있습니까?

답변

0

당신은 텍스트 뷰에 텍스트를 추가 할 수 있습니다

@Override 
public boolean setViewValue(View view, Cursor cursor, int columnIndex) 
{ 
    ((TextView) view).setTextColor(Colors.RED); 
    ((TextView) view).setText(cursor.getString(cursor.getColumnIndex("YOUR-COLUMN-NAME"))); 
    return false; 
} 
0

변화 라인

tv = (TextView)view.findViewById(R.id.countryTextView); // <-- add 'view.' 

전화

conAdapter.setViewBinder(SimpleCursorAdapter.ViewBinder)

setListAdapter(conAdapter); // set adapter 
관련 문제