I am trying to add the new RecyclerView to my project inside a Fragement. I am following a video tutorial on Link1 . When I try to create an adapter for the RecyclerView, I start getting this error. I am using Eclipse Juno. I cant figure out the 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 and RecycleAdapter are giving error "The hierarchy of the type RecycleAdapter is inconsistent". 
In the extends part of the RecycleAdapter, it shows error 
"Bound mismatch: The type RecycleAdapter.MyViewHolder is not a valid substitute for the bounded parameter <VH extends RecyclerView.ViewHolder> of the type RecyclerView.Adapter<VH>". 
Any pointers?
I found the problem. The issue was that I was using an older version and v4 support library which does not contain the class android.support.v4.view.ScrollingView class. I replaced my old v4 library with the new version and the error was gone!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With