android - Sticky Header with recylerview -
i have implemented sticky headers recyclerview. want add 1 textview , 1 imageview above recyclerview while scrolling sticky headers working fine , textview should scrolled above , should not visible.
@override public recyclerview.viewholder oncreateviewholder(viewgroup parent, int viewtype) { if (viewtype == type_item) { //inflating recycle view item layout view itemview = layoutinflater.from(parent.getcontext()).inflate(r.layout.headerview, parent, false); return new itemviewholder(itemview); } else if (viewtype == type_header) { //inflating header view view itemview = layoutinflater.from(parent.getcontext()).inflate(r.layout.list_item, parent, false); return new headerviewholder(itemview); } else return null; } @override public void onbindviewholder(recyclerview.viewholder holder, int position) { if (holder instanceof headerviewholder) { headerviewholder headerholder = (headerviewholder) holder; } else if (holder instanceof itemviewholder) { itemviewholder itemholder = (itemviewholder) holder; } } @override public int getitemcount() { return contactvolist.size(); } @override public int getitemviewtype(int position) { if (position == 0) { return type_header; } return type_item; } private class headerviewholder extends recyclerview.viewholder { public headerviewholder(view view) { super(view); layout = (relativelayout) view.findviewbyid(r.id.layout); } } private class itemviewholder extends recyclerview.viewholder implements view.onclicklistener { textview name; imageview icon; public itemviewholder(view itemview) { super(itemview); itemview.setonclicklistener(this); name = (textview) itemview.findviewbyid(r.id.name); icon = (imageview) itemview.findviewbyid(r.id.icon); } @override public void onclick(view v) { context context = itemview.getcontext(); int position = getadapterposition(); } } }
Comments
Post a Comment