title: Recycler view setLayoutManager on a null object reference
body: <p>In my android app, I want to display data into <code>Recyclerview</code> layout. here I specified some code please refer it. because I don't know what is the reason behind it. Please help me. Thanks in advance.</p>
  
  <p><strong>fragment.xml</strong></p>
  
  <pre><code>&lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="bottom"
      android:orientation="vertical"&gt;
  
      &lt;android.support.v7.widget.RecyclerView
          android:id="@+id/rvDisplay"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginBottom="10dp"
          android:layout_marginLeft="10dp"
          android:layout_marginRight="10dp"&gt;
  
      &lt;/android.support.v7.widget.RecyclerView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Here, I specify raw file of <code>RecyclerView</code>.</p>
  
  <p><strong>raw.xml</strong></p>
  
  <pre><code>&lt;android.support.v7.widget.CardView   xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:card_view="http://schemas.android.com/tools"
      android:id="@+id/cardView"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginBottom="10dp"
      android:layout_marginLeft="10dp"
      android:layout_marginRight="10dp"
      android:layout_marginTop="10dp"
      android:background="@color/colorWhite"
      app:cardElevation="8dp"
      card_view:cardCornerRadius="2dp"
      card_view:cardUseCompatPadding="true"&gt;
  
      &lt;RelativeLayout
          android:id="@+id/footerView"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="bottom"
          android:padding="10dp"&gt;
  
          &lt;android.support.v7.widget.AppCompatTextView
              android:id="@+id/txtListTitle"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text="HMS Scrap"
              android:textColor="@color/colorWhite" /&gt;
  
          &lt;android.support.v7.widget.AppCompatTextView
              android:id="@+id/txtListName"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_below="@+id/txtListTitle"
              android:layout_marginTop="10dp"
              android:text="HMS Scrap"
              android:textColor="@color/colorWhite" /&gt;
  
      &lt;/RelativeLayout&gt;
  
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p>Now, I post adapter file code</p>
  
  <p><strong>adapter.java</strong></p>
  
  <pre><code>public class ListAdapter extends RecyclerView.Adapter&lt;ListAdapter.ListViewHolder&gt; {
      private Context mContext;
      private List&lt;ListModal&gt; listTitle;
  
      public ListAdapter(Context mContext, List&lt;ListModal&gt; listTitle) {
          this.mContext = mContext;
          this.listTitle = listTitle;
      }
  
      @Override
      public ListAdapter.ListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View itemView = LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.raw_list, parent, false);
  
          return new ListAdapter.ListViewHolder(itemView);
      }
  
      @Override
      public void onBindViewHolder(ListAdapter.ListViewHolder holder, int position) {
          ListModal objListModal = listTitle.get(position);
          holder.txtListTitle.setText(objListModal.getList_name());
          holder.txtListTitle.setText(objListModal.getList_title());
      @Override
      public int getItemCount() {
          return 0;
      }
  
      public class ListViewHolder extends RecyclerView.ViewHolder {
          TextView txtListTitle, txtListName;
          CardView cvList;
          public ListViewHolder(View itemView) {
              super(itemView);
  
              txtListTitle = (TextView) itemView.findViewById(R.id.txtListTitle);
              txtListName = (TextView) itemView.findViewById(R.id.txtListName);
              cvList = (CardView) itemView.findViewById(R.id.cardView);
          }
      }
  }
  </code></pre>
  
  <p><strong>Now Fragment.java</strong></p>
  
  <pre><code>RecyclerView rvDisplay;
  private ListAdapter adapter;
  private List&lt;ListModal&gt; lstmodal;
  
  public CreateListFragment() {
      // Required empty public constructor
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
  
      View view = inflater.inflate(R.layout.fragment_create_list, container, false);
  
      rvDisplay = (RecyclerView) view.findViewById(R.id.rvDisplay);
  
      lstmodal = new ArrayList&lt;&gt;();
  
      final LinearLayoutManager layoutManager = new  LinearLayoutManager(getActivity());
      layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
      rvDisplay.setLayoutManager(layoutManager);
      makeJsonArrayRequest();
      return view;
  }
  
  private void makeJsonArrayRequest() {
      String cancel_req_tag = "list";
  
      JsonArrayRequest req = new JsonArrayRequest(URL_FOR_SELECT,
              new Response.Listener&lt;JSONArray&gt;() {
          @Override
          public void onResponse(JSONArray response) {
               Log.d("OnResponse", response.toString());
  
               try {
                   // Parsing json array response
                   // loop through each json object
                   for (int i = 0; i &lt; response.length(); i++) {
  
                       JSONObject jsonObject = response.getJSONObject(i);
                       ListModal objListModal = new ListModal();
                       if (!jsonObject.isNull("list_name")) {
                           objListModal.list_name = jsonObject.getString("list_name"); //here we can fetch webservice field
                       }
                       if (!jsonObject.isNull("list_title")) {
                           objListModal.list_title = jsonObject.getString("list_title"); //here we can fetch webservice field
                       }
  
                       lstmodal.add(i, objListModal);
                   }
  
                   adapter = new ListAdapter(getActivity(), lstmodal);
                   rvDisplay.setItemAnimator(new DefaultItemAnimator());
                   rvDisplay.setAdapter(adapter);
  
               } catch (JSONException e) {
                   e.printStackTrace();
                   Toast.makeText(getActivity(), "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
               }
  
           }
       }, new Response.ErrorListener() {
           @Override
           public void onErrorResponse(VolleyError error) {
               VolleyLog.d("VolleyError", "Error: " + error.getMessage());
               Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
           }
       });
  }
  </code></pre>
  
  <p>Here I have tried this code I am getting this error please see work log</p>
  
  <p><a href="https://i.stack.imgur.com/oIYZU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oIYZU.png" alt="enter image description here"></a></p>