0
누군가가 나를 도와 줄 수 있습니다. 목록보기가 들어있는 레이아웃이 있는데 목록보기의 각 항목에 요일을 나타내는 개별 텍스트 필드가 포함되어 있습니다. -> SMTWTFS 텍스트 항목의 색상을 변경하려면 텍스트 항목의 색상을 변경해야합니다. 데이터 베이스. 이것은 거의 작동하지만 목록보기의 첫 번째 행이 다른 목록 행에 설정된 경우 모든 항목의 색상이 변경되었음을 알았습니다. 커서에서 안드로이드 ViewBinder 값
내 텍스트 항목
은 그때 마지막으로 내가 반환 값이 경우 뷰 바인더의 색상을 설정하려고 어댑터db = new DatabaseHandler(getActivity());
mCursor=db.getReadableDatabase().rawQuery("SELECT rowid _id,* "+
"FROM table", null);
adapter = new SimpleCursorAdapter(getActivity(),
R.layout.list_row, mCursor,
new String[] {DatabaseHandler.KEY_SUNDAY, DatabaseHandler.KEY_MONDAY,DatabaseHandler.KEY_TUESDAY,DatabaseHandler.KEY_WEDNESDAY, DatabaseHandler.KEY_THURSDAY, DatabaseHandler.KEY_FRIDAY,
DatabaseHandler.KEY_SATURDAY,},
new int[] {R.id.textSUN,R.id.textMON, R.id.textTUE, R.id.textWED, R.id.textTHU, R.id.textFRI, R.id.textSAT});
을 내 DB를 조회 및 설정이
textSUN = (TextView) v.findViewById(R.id.textSUN);
textMON = (TextView) v.findViewById(R.id.textMON);
textTUE = (TextView) v.findViewById(R.id.textTUE);
textWED = (TextView) v.findViewById(R.id.textWED);
textTHU = (TextView) v.findViewById(R.id.textTHU);
textFRI = (TextView) v.findViewById(R.id.textFRI);
textSAT = (TextView) v.findViewById(R.id.textSAT);
같이 선언 데이터베이스에서 1
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
@Override
public boolean setViewValue(View view, Cursor cursor, int
columnIndex) {
final int sun_column = cursor.getColumnIndex("sun");
final int mon_column = cursor.getColumnIndex("mon");
final int tue_column = cursor.getColumnIndex("tue");
final int wed_column = cursor.getColumnIndex("wed");
final int thu_column = cursor.getColumnIndex("thu");
final int fri_column = cursor.getColumnIndex("fri");
final int sat_column = cursor.getColumnIndex("sat");
}
if (columnIndex == sun_column) {
int sun = cursor.getInt(cursor.getColumnIndexOrThrow("sun"));
if(sun == 1){
((TextView) view).setTextColor(Color.parseColor("#FFFFFF"));
}
return true;
}
if (columnIndex == mon_column) {
int mon = cursor.getInt(cursor.getColumnIndexOrThrow("mon"));
if(mon == 1){
((TextView) view).setTextColor(Color.parseColor("#FFFFFF"));
}
return true;
}
if (columnIndex == tue_column) {
int tue = cursor.getInt(cursor.getColumnIndexOrThrow("tue"));
if(tue == 1){
((TextView) view).setTextColor(Color.parseColor("#FFFFFF"));
}
return true;
}
if (columnIndex == wed_column) {
int wed = cursor.getInt(cursor.getColumnIndexOrThrow("wed"));
if(wed == 1){
((TextView) view).setTextColor(Color.parseColor("#FFFFFF"));
}
return true;
}
if (columnIndex == thu_column) {
int thu = cursor.getInt(cursor.getColumnIndexOrThrow("thu"));
if(thu == 1){
((TextView) view).setTextColor(Color.parseColor("#FFFFFF"));
}
return true;
}
if (columnIndex == fri_column) {
int fri = cursor.getInt(cursor.getColumnIndexOrThrow("fri"));
if(fri == 1){
((TextView) view).setTextColor(Color.parseColor("#FFFFFF"));
}
return true;
}
if (columnIndex == sat_column) {
int sat = cursor.getInt(cursor.getColumnIndexOrThrow("sat"));
if(sat == 1){
((TextView) view).setTextColor(Color.parseColor("#FFFFFF"));
}
return true;
}
return false;
}
});
lv = (ListView) v.findViewById(R.id.listView);
lv.setAdapter(adapter);
아마도 나는이 모든 잘못에 대해 갈거야 ?? 그것은 거의 작동하지만.
많은 감사