title: Load Entire RecyclerView but only display 50 Items unless using Search Bar
body: <p>I have a JSON List RecyclerView that I created with Volley. My recyclerview has about 1000 items, but I only want to display 50 items but still have all the items loaded from the JSON so when the user uses the search tool it will search the entire JSON data. </p>
  
  <p>I can get my recyclerview to show the amount I want, 50,but then when I use the search tool I only can search the 50.ive looked for answers but can't seem to find any on how to load all items but only display 50. Can anyone help? </p>
  
  <p><i>MainActivity</i></p>
  
  <pre><code>public class HomeFragment extends Fragment {
  
  public static final String URL_DATA = "https://api.coinmarketcap.com/v1/ticker/";
  private RecyclerView.Adapter adapter;
  private List&lt;ListItem&gt; listItems;
  private RecyclerView recyclerView;
  private EditText SearchText;
  
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      View v = inflater.inflate(R.layout.fragment_home, container, false);
  
      listItems = new ArrayList&lt;&gt;();
      recyclerView = (RecyclerView) v.findViewById(R.id.recyclerView);
      SearchText = (EditText) v.findViewById(R.id.search_text);
  
      recyclerView.setHasFixedSize(true);
      recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
      loadRecyclerViewData();
  
      SearchText.addTextChangedListener(new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
          }
  
          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
          }
  
          @Override
          public void afterTextChanged(Editable editable) {
              filter(editable.toString());
          }
      });
  
      return v;
  }
  
  
  private void filter(String text){
      List&lt;ListItem&gt; filteredList = new ArrayList&lt;&gt;();
  
      for(ListItem item :listItems ){
          if (item.getHead().toLowerCase().contains(text.toLowerCase()) &amp;&amp; item.getDesc().toLowerCase().contains(text.toLowerCase())){
              filteredList.add(item);
          }
      }
      adapter = new MyAdapter(filteredList, getContext());
      recyclerView.setAdapter(adapter);
  }
  private void loadRecyclerViewData() {
      final ProgressDialog progressDialog = new ProgressDialog(getContext());
      progressDialog.setMessage("Loading Data...");
      progressDialog.show();
  
      StringRequest stringRequest = new StringRequest(Request.Method.GET,
              URL_DATA,
              new Response.Listener&lt;String&gt;() {
                  @Override
                  public void onResponse(String response) {
                      progressDialog.dismiss();
                      try {
                          JSONArray array = new JSONArray(response);
                          for(int i=0; i &lt; array.length(); i++){
                              JSONObject o = array.getJSONObject(i);
                              ListItem item = new ListItem(
                                      o.getString("name"),
  
                              );
  
                              listItems.add(item);
                          }
                          adapter = new MyAdapter(listItems, getContext());
                          recyclerView.setAdapter(adapter);
  
                      } catch (JSONException e) {
                          e.printStackTrace();
                      }
  
                  }
              },
              new Response.ErrorListener() {
                  @Override
                  public void onErrorResponse(VolleyError error) {
                      progressDialog.dismiss();
                      Toast.makeText(getContext(),error.getMessage(), Toast.LENGTH_LONG).show();
  
                  }
              });
  
      RequestQueue requestQueue = Volley.newRequestQueue(getContext());
      requestQueue.add(stringRequest);
  }
  }
  </code></pre>
  
  <p><i>MyAdapter</i></p>
  
  <pre><code>public class MyAdapter extends RecyclerView.Adapter&lt;MyAdapter.ViewHolder&gt; {
  private List&lt;ListItem&gt; listItems;
  private Context context;
  
  public MyAdapter(List&lt;ListItem&gt; listItems, Context context) {
      this.listItems = listItems;
      this.context = context;
  }
  
  @NonNull
  @Override
  public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
      View v = LayoutInflater.from(parent.getContext())
              .inflate(R.layout.list_item, parent, false);
  
      return new ViewHolder(v);
  
  }
  
  @Override
  public void onBindViewHolder(@NonNull final ViewHolder holder, final int position) {
      final ListItem listItem = listItems.get(position);
  
      holder.textViewHead.setText(listItem.getHead());
      holder.textViewDesc.setText(listItem.getDesc());
  
  public void filterList(ArrayList&lt;ListItem&gt; filteredList){
      this.listItems = filteredList;
      notifyDataSetChanged();
  }
  
  
  @Override
  public int getItemCount() {
      return listItems.size();
  }
  
  public class ViewHolder extends RecyclerView.ViewHolder {
  
      public TextView textViewHead;
      public TextView textViewDesc;
  
      public ViewHolder(View itemView) {
          super(itemView);
  
          textViewHead = (TextView) itemView.findViewById(R.id.textViewHead);
          textViewDesc = (TextView) itemView.findViewById(R.id.textViewDesc);
      }
  }
  }
  </code></pre>