0

I am making an app with 100 list items and was wondering if I could get away with not implementing the RecyclerView as I find it hard to implement it.

ledzee
  • 301
  • 2
  • 3
  • 16
  • Check this post [Should we use RecyclerView to replace ListView?](http://stackoverflow.com/questions/28392554/should-we-use-recyclerview-to-replace-listview) – Xcihnegn Mar 28 '15 at 09:59

2 Answers2

1

Quite frankly it depends up to you, Listview makes it easy for you by taking a lot of responsibility which makes it slow at time when you have to show a lot of data, on other hand RecyclerView does what it is best at make's things fast by taking care or bare minimum structure.

RecyclerView is quite easy to implement and you will get chance to learn some of the touch framework of Android because of it.

And performing Animation on RecyclerView is quite easy as well and way better than Listview

Making a custom listview is piece of cake with RecyclerView

here's an example for RecyclerView

 private RecyclerView recyclerView;
recyclerView = (RecyclerView)findViewById(R.id.recycler);
    MyViewComplainAdapter adapter = new MyViewComplainAdapter(getApplicationContext(), createComplainList());
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));

in XML

 <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scrollbars="vertical" />

your Adapter (Whatever you want to call this thing... lol )

 private class MyViewComplainAdapter extends RecyclerView.Adapter<MyViewComplainAdapter.MyViewComplainViewHolder>{

    private Context _Context;
    private ArrayList<ViewMyComplainData> _List;
    private LayoutInflater _Inflater;

    public MyViewComplainAdapter(Context context, ArrayList<ViewMyComplainData> list){
        _Context = context;
        _List = list;
        _Inflater = LayoutInflater.from(_Context);
    }

    @Override
    public MyViewComplainViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View layout = _Inflater.inflate(R.layout.single_item_view_my_complain,parent,false);
        MyViewComplainViewHolder holder = new MyViewComplainViewHolder(layout);
        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewComplainViewHolder holder, int position) {
        ViewMyComplainData data = _List.get(position);
        holder.complaint_number.setText(data.getComplaint_Number()+"");
        holder.complaint_type.setText(data.getComplaint_Type()+"");
        holder.status.setText(data.getStatus()+"");
    }

    @Override
    public int getItemCount() {
        return _List.size();
    }

    public class MyViewComplainViewHolder extends RecyclerView.ViewHolder{
        TextView complaint_number;
        TextView complaint_type;
        TextView status;

        public MyViewComplainViewHolder(View itemView) {
            super(itemView);
            complaint_number = (TextView)itemView.findViewById(R.id.textView_complaint_number_single_item_view_my_complain);
            complaint_type = (TextView)itemView.findViewById(R.id.textView_complaint_type_single_item_view_my_complain);
            status= (TextView)itemView.findViewById(R.id.textView_status_single_item_view_my_complain);
        }
    }
}

yes you will have to make a ArrayList<ViewMyComplainData> using this method createComplainList(), you should figure this out

Pankaj Nimgade
  • 4,529
  • 3
  • 20
  • 30
0

Technically speaking, RecyclerView doesn't need anything like "notifyDataSetChanged()" when an item is added or deleted from your List, which is a huge improvement performance-wise.

Hulk
  • 237
  • 1
  • 13