onBindViewHolder cannot find views
<p>I am inflating my layout xml in a <code>recyclerview</code> adapter. But i am running into an <strong>NPE</strong> everytime and cannot seem to locate the root of the problem. </p>

<p>Here's my logcat:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NullPointerException
at com.softtech.stevekamau.buyathome.adapter.RecomGridAdapter.onBindViewHolder(RecomGridAdapter.java:159)
 at com.softtech.stevekamau.buyathome.adapter.RecomGridAdapter.onBindViewHolder(RecomGridAdapter.java:120)
  at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5217)
  at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5250)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4487)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4363)
   at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961)
   at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370)
   at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333)
    at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562)
     at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900)
     at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3071)
     at android.view.View.layout(View.java:13754)
     at android.view.ViewGroup.layout(ViewGroup.java:4362)
     
     .......</code></pre>
</div>
</div>
</p>

<p>And my adapter:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>public class RecomGridAdapter extends RecyclerView.Adapter&lt;RecomGridAdapter.ViewHolder&gt; {
    private List&lt;NewModel&gt; modelItems;

    // Provide a reference to the views for each data item
    // Complex data items may need more than one view per item, and
    // you provide access to all the views for a data item in a view holder
    public static class ViewHolder extends RecyclerView.ViewHolder {
        // each data item is just a string in this case
        public TextView mTextView;

        public ViewHolder(View v) {
            super(v);
            mTextView = (TextView) v.findViewById(R.id.name);
        }
    }

    // Provide a suitable constructor (depends on the kind of dataset)
    public RecomGridAdapter(List&lt;NewModel&gt; modelItems) {
        this.modelItems = modelItems;
    }

    // Create new views (invoked by the layout manager)
    @Override
    public RecomGridAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                        int viewType) {
        // create a new view
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.grid_cell, parent, false);
        // set the view's size, margins, paddings and layout parameters

        return new ViewHolder(v);
    }

    // Replace the contents of a view (invoked by the layout manager)
    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        // - get element from your dataset at this position
        // - replace the contents of the view with that element
        NewModel m = modelItems.get(position);
        holder.mTextView.setText(m.getName());

    }

    // Return the size of your dataset (invoked by the layout manager)
    @Override
    public int getItemCount() {
        return modelItems.size();
    }
}</code></pre>
</div>
</div>
</p>

<p>And my <strong>grid_cell.xml:</strong></p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:foobar="http://schemas.android.com/apk/res-auto"
    android:layout_width="118dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"&gt;

    &lt;android.support.v7.widget.CardView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/list_row_selector"
        card_view:cardCornerRadius="3dp"&gt;

        &lt;LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"&gt;

            &lt;com.android.volley.toolbox.NetworkImageView
                android:id="@+id/thumbnail"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_centerHorizontal="true"
                android:layout_margin="5dp"
                android:scaleType="centerCrop"
                android:src="@drawable/loading4" /&gt;

            &lt;RelativeLayout
                android:layout_width="110dp"
                android:layout_height="60dp"&gt;

                &lt;ImageView
                    android:id="@+id/options"
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:layout_alignParentRight="true"
                    android:src="@drawable/options" /&gt;

                &lt;com.ctrlplusz.anytextview.AnyTextView
                    android:id="@+id/title"
                    android:layout_width="70dp"
                    android:layout_height="35dp"
                    android:ellipsize="end"
                    android:ems="10"
                    android:gravity="start"
                    android:maxLines="2"
                    android:paddingLeft="5dp"
                    android:text="Samsungf usb cablexvndvnsddvjdbv"
                    android:textSize="14dp"
                    android:textStyle="bold"
                    foobar:typeface="Gudea-Regular.ttf" /&gt;

                &lt;com.ctrlplusz.anytextview.AnyTextView
                    android:id="@+id/amount"
                    android:layout_width="110dp"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/title"
                    android:ellipsize="end"
                    android:ems="10"
                    android:paddingLeft="5dp"
                    android:singleLine="true"
                    android:text="10000000000"
                    android:textColor="#cf5862"
                    android:textSize="18dp"
                    foobar:typeface="Gudea-Bold.ttf" /&gt;
            &lt;/RelativeLayout&gt;
        &lt;/LinearLayout&gt;
    &lt;/android.support.v7.widget.CardView&gt;
&lt;/LinearLayout&gt;</code></pre>
</div>
</div>
</p>

<p>The logcat suggests that this line:</p>

<pre><code>  holder.mTextView.setText(m.getName());
</code></pre>

<p>Is where my exception occurs.
And <code>m.getName()</code> is definately not null or even the problem because i have tried <code>holder.mTextView.setText("Test");</code>.</p>

<p>Any ideas what exactly is happening?</p>