android - Heterogenous Layouts inside RecyclerView -


i developing weather app in wanted use 2 views inside recyclerview having cursoradapter member. want use 1 view display todays weather , other view display other days weathers. recyclerview working if use 1 view display weather. have overwritten getitemviewtype()? know whichview` type should inflate.

code getitemviewtype():

private static int view_type_today = 0; private static int view_type_future_day = 1;  @override     public int getitemviewtype(int position) {         if(position == view_type_today)             return view_type_today;         else             return view_type_future_day; } 

code newview() of cursoradapter have overwritten:

@override public view newview(context context, cursor cursor, viewgroup parent) {     int viewtype = getitemviewtype(cursor.getposition());     int layoutid = -1;     if(viewtype==view_type_today)         layoutid = r.layout.list_item_forecast_today;     else if(viewtype==view_type_future_day)         layoutid = r.layout.list_item_forecast;     view view = layoutinflater.from(context).inflate(layoutid, parent, false);     return view; } 

no matter value of position in getitemviewtype() is, function returning view_type_today.

can please tell doing wrong?

overriding getitemviewtype not enough have listview heterogeneous rows. need override getviewtypecount() well, in order return number of heterogeneous rows want have (2 in case). please remember getitemviewtype has return continuos integers in range [0, getviewtypecount() -1]


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -