Advertisement
Guest User

Untitled

a guest
Mar 26th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Java
  2. public class MyAdapter extends RecyclerView.Adapter<RecyclerAdapter.ListViewHolder> {
  3.  
  4.     private ArrayList<MyRepo> myRepoList;
  5.  
  6.     public RecyclerAdapter(ArrayList<MyRepo> myRepoList) {
  7.         this.myRepoList = myRepoList;
  8.     }
  9.    
  10.     // ....
  11.    
  12.     public void setFilter(List<MyRepo> list) {
  13.         myRepoList = new ArrayList<>();
  14.         myRepoList.addAll(list);
  15.         notifyDataSetChanged();
  16.     }
  17. }
  18.  
  19. // Kotlin
  20. class MyAdapter (private var myRepoList: ArrayList<MyRepo>) : RecyclerView.Adapter<RecyclerAdapter.ListViewHolder>() {
  21.    
  22. // ....
  23.  
  24.     fun setFilter(list: List<MyRepo>) {
  25.         myRepoList = ArrayList<MyRepo>()
  26.         myRepoList.addAll(list!!)
  27.         notifyDataSetChanged()
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement