android - Problems with setting two layoutsType at CursorAdapter -


i trying set cursor adapter 2 different layouts, first 1 must unique, others - same, getitemviewtype(cursor.getposition()); return 0...

here adapter:

public class myadapter extends cursoradapter

public static class viewholder {   public viewholder (view rootview){}}  public profileadapter(activity activity, cursor c) {         super(activity, c);         mactivity = activity;     }  @override     public view newview(context context, cursor cursor, viewgroup parent) {         int mlayoutid = -1;         mviewtype = getitemviewtype(cursor.getposition());         if (mviewtype == view_type_main){             mlayoutid = r.layout.main;         } else {             mlayoutid = r.layout.list_items;         }          view rootview = layoutinflater.from(context).inflate(mlayoutid, parent, false);         viewholder viewholder = new viewholder(rootview);         rootview.settag(viewholder);         return rootview;      }   @override     public void bindview(view view, context context, cursor cursor) {         mcursor = cursor;         mview = view;         mviewholder = (viewholder) view.gettag();         mviewtype = getitemviewtype(cursor.getposition());         if (mviewtype == view_type_main){          } else {         }     } 

feeling missing simple... glad ideas how solve staff!

your adapter must implement getviewtypecount() (and return 2 in case) , implement getitemviewtype(). default implementation got no idea data , won't try figure out. handle case there 1 view type used (hence 0 returned). add missing methods , should good.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -