SHARE
TWEET

Untitled

a guest Jan 24th, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import android.util.Log;
  2. import android.view.LayoutInflater;
  3. import android.view.View;
  4. import android.view.ViewGroup;
  5.  
  6. import androidx.annotation.NonNull;
  7.  
  8. import androidx.recyclerview.widget.RecyclerView;
  9.  
  10. import com.easy.myapplication1236.R;
  11.  
  12. import java.util.List;
  13.  
  14. public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
  15.  
  16.     private List<TestModel> notes ;
  17.     private ItemClickListener itemClickListener;
  18.  
  19.     public RecyclerViewAdapter(List<TestModel> notes, ItemClickListener itemClickListener) {
  20.         this.notes = notes;
  21.         this.itemClickListener = itemClickListener;
  22.     }
  23.  
  24.     @NonNull
  25.     @Override
  26.     public WithTitle onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
  27.         View itemView = LayoutInflater.from(parent.getContext())
  28.                 .inflate(R.layout.adapter_view, parent, false);
  29.         return new WithTitle(itemView, itemClickListener);
  30.     }
  31.  
  32.     @Override
  33.     public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
  34.         TestModel currentNote = notes.get(position);
  35.  
  36.         WithTitle noteHolder = (WithTitle) holder;
  37.  
  38.         noteHolder.bind(currentNote);
  39.  
  40.     }
  41.  
  42.  
  43.     @Override
  44.     public int getItemCount() {
  45.         return notes.size();
  46.     }
  47.  
  48.     public interface ItemClickListener {
  49.         void onItemClick(int id);
  50.     }
  51.  
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top