0

I am implementing the recyler view in android.The arraylist shows the correct size of list,when i debug the code the adapter also get set.But list items are not displaying may be due createViewHolder and bindviewHolder.Below is the code of RecyclerViewAdapter

MyAdapter.java

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
    public Context c;
    View img_View;
    File file;
    public ArrayList<Bean> arr= new ArrayList<>();
    LayoutInflater inflator;

    public MyAdapter(Context applicationContext, ArrayList<Bean> arr) {
        this.c = applicationContext;
        this.arr= arr;
        inflator =  LayoutInflater.from(c.getApplicationContext());
    }

    @Override
    public MyAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        img_View =inflator.inflate(R.layout.list_row, parent, false);
        return new MyViewHolder(img_View);
    }

    @Override
    public void onBindViewHolder(MyAdapter.MyViewHolder holder, int position) {
                holder.title.setText(arr.get(position).gettitle());

    }

    @Override
    public int getItemCount() {
        return arr.size();
    }
    public class MyViewHolder extends RecyclerView.ViewHolder {

        public TextView desc, title;


        public MyViewHolder(View view) {
            super(view);

            title = (TextView) view.findViewById(R.id.tv_title);

        }
    }

1 Answer 1

2
    img_View = LayoutInflater.from(context).inflate(R.layout.list_row, parent, false);
      return new MyViewHolder(img_View);
1
  • I have already tried this,but not working.Any other solution please Commented Feb 14, 2017 at 4:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.