データベースからのエントリを表示しているリストビューでテキストの色を変更しようとしています。問題は、目に見えないテキストが表示されることです (または、このリストのエントリを区切る行のみが表示されます) が、エントリをクリックすると、このエントリの詳細が表示されます。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);
どうすれば正常に動作するように変更できますか?