android - How could a custom cursor adaptor handle multiple layout? -
i newbie on android developing.
i have listview contains 2 layout
user_id | name | food 1 | john | apple 1 | john | banana
which indicates have 2 food preference. use custom cursoradapter populate data ui. show layout in way
name (first list item) food1 (second list item , should repeat afterwards) food2 food3
in order work built 2 listview layouts - 1 name display , 1 showing preference food. list item has 2 entries cursoradapter, ran 2 times. app runs run following
john banana
it missed apple.
here bindview code in cursoradapter
@override public void bindview(view view, final context context, cursor cursor) { viewholder viewholder = (viewholder) view.gettag(); int viewtype = getitemviewtype(cursor.getposition()); switch (viewtype) { case view_type_name: { string namestring = cursor.getstring(fragment.col_question); viewholder.questionview.settext(namestring); break; } case view_type_food: { string foodstring = cursor.getstring(fragment.col_answer); viewholder.answerview.settext(foodstring); break; } } }
i not sure how 3 items loaded.
thanks in advance
Comments
Post a Comment