android - RecyclerView Adapter gives error "The hierarchy of the type RecycleAdapter is inconsistent" -
i trying add new recyclerview
project inside fragement
. following video tutorial on link1 . when try create adapter recyclerview
, start getting error. using eclipse juno. cant figure out problem. please help
my code:
public class recycleadapter extends recyclerview.adapter<recycleadapter.myviewholder> { private layoutinflater inflator; list <item> data = collections.empty_list; public recycleadapter(context context, list<item> data){ inflator = layoutinflater.from(context); } @override public int getitemcount() { // todo auto-generated method stub return data.size(); } @override public myviewholder oncreateviewholder(viewgroup parent, int arg1) { view view = inflator.inflate(r.layout.row_staggered_new, parent, false); myviewholder holder = myviewholder(view); return holder; } @override public void onbindviewholder(myviewholder holder, int position) { item current = data.get(position); holder.text.settext(current.title); holder.image.setimageresource(current.image); } public static class myviewholder extends recyclerview.viewholder{ public imageview image; public textview text; public myviewholder(view itemview) { super(itemview); image = (imageview) itemview.findviewbyid(r.id.imageview1); text = (textview) itemview.findviewbyid(r.id.textview1); } } }
both myviewholder
, recycleadapter
giving error "the hierarchy of type recycleadapter inconsistent"
. in extends part of recycleadapter
, shows error "bound mismatch: type recycleadapter.myviewholder not valid substitute bounded parameter <vh extends recyclerview.viewholder> of type recyclerview.adapter<vh>"
.
any pointers?
i found problem. issue was using older version , v4 support library not contain class android.support.v4.view.scrollingview class. replaced old v4 library new version , error gone!
Comments
Post a Comment