how to customize row layout depending on cursor specific value? Guess I need to customize bindChildView - but how? :)
Main function:
public void fillQuestions(int id) {
Cursor questionsCursor = db.getQuestions(id);
EventActivity.this.startManagingCursor(questionsCursor);
questionsCursor.moveToFirst();
ExpandableListView questionsList = (ExpandableListView) findViewById(R.id.elv_questions);
ExpandableQuestionsAdapter adapter = new ExpandableQuestionsAdapter(
questionsCursor,
EventActivity.this,
R.layout.display_name_row,
R.layout.display_cb_answer_row,
new String[] {"questionText"},
new int[] {R.id.r_lv_name},
new String[] {"answerName"},
new int[] {R.id.r_lv_cb_name});
}
Adapter:
public class ExpandableQuestionsAdapter extends SimpleCursorTreeAdapter {
public ExpandableQuestionsAdapter(Cursor cursor, Context context, int groupLayout,
int childLayout, String[] groupFrom, int[] groupTo, String[] childrenFrom,
int[] childrenTo) {
super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childrenFrom, childrenTo);
}
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
Cursor childCursor = db.getAnswers(groupCursor.getInt(groupCursor.getColumnIndex(KEY_F_ID)));
EventActivity.this.startManagingCursor(childCursor);
childCursor.moveToFirst();
return childCursor;
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
View rowView = super.getChildView(groupPosition, childPosition, isLastChild, convertView, parent);
return rowView;
}
@Override
protected void bindChildView(View view, Context context, Cursor cursor, boolean isLastChild) {
super.bindChildView(view, context, cursor, isLastChild);
}
}
I tried to look for some examples, unfortunately couldn't;t find any - any help appreciated
Thanks, Jakub
i am not big proffecional but maybe my research can help you
in my case i have specific column COLOR that have color value like #1B3F51B5 also instead of view.setBackgroundColor you can use something like this