title: Recycle view - java.lang.NullPointerException
body: <p>I am getting following exception while i'm try to display recycle view:</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.support.v7.widget.RecyclerView$LayoutManager.canScrollVertically()' on a null object reference
  at android.support.v7.widget.RecyclerView.computeVerticalScrollRange(RecyclerView.java:1216)
      at android.view.View.onDrawScrollBars(View.java:13900)
      at android.view.View.draw(View.java:16275)
      at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:2440)
      at android.view.View.updateDisplayListIfDirty(View.java:15192)
      at android.view.View.getDisplayList(View.java:15215)
      at android.view.View.draw(View.java:15990)
      at android.view.ViewGroup.drawChild(ViewGroup.java:3708)
      at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3502)
      at android.view.View.draw(View.java:16272)
      at android.view.View.updateDisplayListIfDirty(View.java:15192)
      at android.view.View.getDisplayList(View.java:15215)
      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3692)
      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3671)
      at android.view.View.updateDisplayListIfDirty(View.java:15152)
      at android.view.View.getDisplayList(View.java:15215)
      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3692)
      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3671)
      at android.view.View.updateDisplayListIfDirty(View.java:15152)
      at android.view.View.getDisplayList(View.java:15215)
      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:362)
      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3671)
      at android.view.View.updateDisplayListIfDirty(View.java:15152)
      at android.view.View.getDisplayList(View.java:15215)
      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3692)
      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3671)
      at android.view.View.updateDisplayListIfDirty(View.java:15152)
      at android.view.View.getDisplayList(View.java:15215)
      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3692)
      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3671)
      at android.view.View.updateDisplayListIfDirty(View.java:15152)
      at android.view.View.getDisplayList(View.java:15215)
      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3692)
      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3671)
      at android.view.View.updateDisplayListIfDirty(View.java:15152)
      at android.view.View.getDisplayList(View.java:15215)
      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3692)
      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3671)
      at android.view.View.updateDisplayListIfDirty(View.java:15152)
      at android.view.View.getDisplayList(View.java:15215)
      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3692)
      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3671)
      at android.view.View.updateDisplayListIfDirty(View.java:15152)
      at android.view.View.getDisplayList(View.java:15215)
      at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3692)
      at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3671)
      at android.view.View.updateDisplayListIfDirty(View.java:15152)
      at android.view.View.getDisplayList(View.java:15215)
      at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:307)
      at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:313)
      at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:352)
      at android.view.ViewRootImpl.draw(ViewRootImpl.java:2811)
      at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2634)
      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2222)
      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1230)
      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6726)
      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
      at android.view.Choreographer.doCallbacks(Choreographer.java:590)
      at android.view.Choreograph
  </code></pre>
  
  <p>and my xml is this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      style="@style/global_screen_linear_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;LinearLayout
          android:id="@+id/lilAdvancedSearchParent"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="@color/gray_general"
          android:gravity="center_vertical"
          android:orientation="horizontal"
          android:padding="10dp" &gt;
  
          &lt;LinearLayout
              android:id="@+id/lilAdvancedSearch"
              android:layout_width="0dp"
              android:layout_height="match_parent"
              android:layout_weight="6"
              android:gravity="center_vertical" &gt;
  
              &lt;ImageView
                  android:id="@+id/imageView2"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:src="@drawable/arrow_white" /&gt;
  
              &lt;TextView
                  android:id="@+id/txvAvencedSearch"
                  android:layout_width="0dp"
                  android:layout_height="wrap_content"
                  android:layout_marginRight="10dp"
                  android:layout_weight="4.5"
                  android:text="@string/global_fragment_advenced_search"
                  android:textColor="@color/white"
                  android:textSize="@dimen/global_screen_layout_text_view_advenced_search"
                  android:textStyle="bold" /&gt;
          &lt;/LinearLayout&gt;
  
          &lt;EditText
              android:id="@+id/edtSearch"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_weight="9"
              android:drawableLeft="@drawable/navigation_search"
              android:ems="10"
              android:imeOptions="actionSearch"
              android:inputType="text"
              android:textColor="@color/white"
              android:textColorHint="@color/white"
              android:textSize="15sp" &gt;
  
              &lt;requestFocus /&gt;
          &lt;/EditText&gt;
      &lt;/LinearLayout&gt;
  
      &lt;android.support.v7.widget.RecyclerView
                  android:id="@+id/my_recycler_view"
                  android:layout_width="match_parent"
                  android:layout_height="800dp"
                  android:scrollbars="vertical" &gt;
              &lt;/android.support.v7.widget.RecyclerView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>and my java code is this:</p>
  
  <pre><code>public class TendersFragment extends BaseFragment{
  
  
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View v = inflater.inflate(R.layout.global_screen_layout, container, false);
          initUI(v);
          initListeners();
          setEditSearchHint(getString(R.string.tenders_fragment_search_tenders));
          setAdvancedSearchBackground(getResources().getColor(R.color.green_general));
          return v;
      }
  
      @Override
      protected void initUI(View view) {
          lsvTendersJobsMessages = (ListView) view.findViewById(R.id.lsvGlobal);
  
          mRecyclerView = (RecyclerView) view.findViewById(R.id.my_recycler_view);
          setAdapterForListview(lsvTendersJobsMessages);  
  
          edtSearch = (EditText) view.findViewById(R.id.edtSearch);
          txvAdvencedSearch = (TextView) view.findViewById(R.id.txvAvencedSearch);
          lilAdvancedSearch = (LinearLayout) view.findViewById(R.id.lilAdvancedSearch);       
          lilAdvancedSearchParent = (LinearLayout) view.findViewById(R.id.lilAdvancedSearchParent);
  
  
      }
  
      @Override
      protected void setAdapterForListview(ListView lsv) {
          mRecyclerView.setHasFixedSize(true);
          mLinearLayoutManager = new LinearLayoutManager(getActivity());
          mLinearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);      
          mRecyclerView.setLayoutManager(mLinearLayoutManager);
  
          ArrayList&lt;ItemType&gt; arlItems = new ArrayList&lt;ItemType&gt;();
          arlItems.add(ItemType.MAIN_ITEM);
          arlItems.add(ItemType.MAIN_ITEM);
          arlItems.add(ItemType.MAIN_ITEM);
          arlItems.add(ItemType.MAIN_ITEM);
          arlItems.add(ItemType.MAIN_ITEM);
          arlItems.add(ItemType.MAIN_ITEM);
          arlItems.add(ItemType.MAIN_ITEM);
          arlItems.add(ItemType.MAIN_ITEM);
          arlItems.add(ItemType.MAIN_ITEM);
  
          // specify an adapter (see also next example)
          mainItemAdapter = new MainItemAdapter(arlItems, getActivity());
          mRecyclerView.setAdapter(mainItemAdapter);
      }
  
      @Override
      protected void onServiceConnected() {
          // TODO Auto-generated method stub
  
      }
  
  
      protected void initListeners() {
  
          final AdvancedSearchFragment advancedSearchFragment = new AdvancedSearchFragment(); 
          Bundle bundle = new Bundle();       
          bundle.putInt(FragmentConst.BUNDLE_KEY_INT_WHICH_FRAGMENT,FragmentConst.TENDERS_ID);    
          advancedSearchFragment.setArguments(bundle);
          lilAdvancedSearch.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {                   
                     getActivity().getSupportFragmentManager().beginTransaction()
                      .add(android.R.id.content,advancedSearchFragment).addToBackStack(null)
                      .commit();
              }
          });
      }
  }
  </code></pre>
  
  <p>i'm also try to set the layout_height of the recycle view as match_parent and wrap_contant but still i get the same error</p>