android - RecyclerView Display TextView At Top -


i using recyclerview cardview display different text in cards looks

enter image description here

but want text view @ top displays 1 time this

enter image description here

should make separate layout textview , call in same activity? think that's not recommended

you should try getitemtype inside adapter

private static final int type_header = 0; private static final int type_cell = 1;  @override public int getitemviewtype(int position) {     if (position == 0)         return type_header;     else         return type_cell; }  @override public recyclerview.viewholder oncreateviewholder(viewgroup parent, int viewtype) {     view convertview;     switch (viewtype) {         case type_header:             convertview = layoutinflater.from(context).inflate(r.layout.mytextview, parent, false);             return new mytextviewviewholder(convertview);         case type_cell:             convertview = layoutinflater.from(context).inflate(r.layout.mycell, parent, false);             return new cellviewholder(convertview);     }     return null; }  @override public void onbindviewholder(recyclerview.viewholder holder, int position) {     switch (getitemviewtype(position)) {         case type_header:             ((mytextviewviewholder) holder) ...             break;         case type_cell:             ((cellviewholder) holder) ...             break;     } } 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -