android recyclerview adapter code example

Example 1: how to add recyclerview support in android studio

dependencies {
    implementation 'com.android.support:recyclerview-v7:28.0.0'
}

Example 2: RECYCLER VIEW

Elective Subjects Notes

Example 3: remove item from adapter android recyclerview

private void removeItem(int position) {
    int newPosition = holder.getAdapterPosition();
    model.remove(newPosition);
    notifyItemRemoved(newPosition);
    notifyItemRangeChanged(newPosition, model.size());
}

Example 4: recyclerview layout oncreatw

@Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_listitem,parent,false);
        ViewHolder Holder = new ViewHolder(view);
        return Holder;
    }

Tags:

Misc Example