title: NullPointerException custom listview adapter
body: <p>Hello stackoverflow community,</p>
  
  <p>I'm getting a NPE in my getView method of my custom adapter class which extends BaseAdapter. I hope you can help me.</p>
  
  <p>Here's my getView method:</p>
  
  <pre><code>@Override
  public View getView(int pos, View convertView, ViewGroup viewGroup) {
      if(convertView==null){
          LayoutInflater inflater = (LayoutInflater)context
          .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          convertView = inflater.inflate(R.layout.row, null);
      }
  
      TextView datetv = (TextView) convertView.findViewById(R.id.date);
      TextView valuetv = (TextView) convertView.findViewById(R.id.value);
      TextView cattv = (TextView) convertView.findViewById(R.id.cat);
  
      if(values.get(pos)&gt;VALUE_MIN&amp;&amp;values.get(pos)&lt;VALUE_MAX){
          datetv.setTextColor(context.getResources().getColor(R.color.Good));
          valuetv.setTextColor(context.getResources().getColor(R.color.Good));
          cattv.setTextColor(context.getResources().getColor(R.color.Good));
      }
      else{
          datetv.setTextColor(context.getResources().getColor(R.color.Bad));
          valuetv.setTextColor(context.getResources().getColor(R.color.Bad));
          cattv.setTextColor(context.getResources().getColor(R.color.Bad));
      }
  
      datetv.setText(dates.get(pos));
      valuetv.setText(Double.toString(values.get(pos)));
      cattv.setText(cats.get(pos));
  
      LinearLayout l = (LinearLayout) convertView.findViewById(R.id.notelayout);
      l.setFocusableInTouchMode(false);
      l.setFocusable(false);
      l.setOnClickListener(this);
      l.setId(pos);
  
      return convertView;
  }
  </code></pre>
  
  <p>This is row.xml:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
  
  &gt;
  &lt;LinearLayout
      android:orientation="vertical"
      android:layout_width="140dip"
      android:layout_height="wrap_content" 
      android:padding="4dip"
      &gt;
  &lt;TextView 
  android:id="@+id/date" 
  android:layout_width="fill_parent" 
  android:layout_height="24dip" 
  android:textSize="15dip"
  android:gravity="left"  android:paddingLeft="6dip" 
  android:layout_weight="1" /&gt;
  &lt;TextView 
  android:id="@+id/cat" 
  android:layout_width="fill_parent" 
  android:layout_height="24dip" 
  android:textSize="15dip"
  android:gravity="left"  android:paddingLeft="6dip"  
  android:layout_weight="1" /&gt;
  &lt;/LinearLayout&gt;
  &lt;LinearLayout
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" 
      android:layout_weight="1"
      android:gravity="center"
      android:padding="4dip"
      &gt;
      &lt;TextView 
  android:id="@+id/value" 
  android:layout_width="fill_parent" 
  android:layout_height="48dip" 
  android:textSize="40dip"
  android:gravity="center"
  /&gt;
  &lt;/LinearLayout&gt;
  &lt;LinearLayout
      android:id="@+id/notelayout"
      android:orientation="vertical"
      android:layout_width="50dip"
      android:layout_height="wrap_content" 
      android:gravity="right"
      android:layout_gravity="center"
      android:padding="4dip"
      &gt;
  &lt;ImageView
  android:id="@+id/note" 
  android:layout_width="wrap_content" 
  android:layout_height="48dip" 
  android:gravity="center"
  android:src="@drawable/papiertje"
  android:scaleType="centerInside"/&gt;
  &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And this is the error I'm getting:</p>
  
  <pre><code>01-30 00:34:31.772: ERROR/AndroidRuntime(497): FATAL EXCEPTION: main
  01-30 00:34:31.772: ERROR/AndroidRuntime(497): java.lang.NullPointerException
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at com.yellos.android.glucose.ListViewAdapter.getView(ListViewAdapter.java:85)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.widget.AbsListView.obtainView(AbsListView.java:1294)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1198)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.widget.ListView.onMeasure(ListView.java:1109)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.view.View.measure(View.java:8171)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:696)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:306)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.view.View.measure(View.java:8171)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.view.View.measure(View.java:8171)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.view.View.measure(View.java:8171)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.view.View.measure(View.java:8171)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.os.Handler.dispatchMessage(Handler.java:99)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.os.Looper.loop(Looper.java:123)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at android.app.ActivityThread.main(ActivityThread.java:4627)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at java.lang.reflect.Method.invokeNative(Native Method)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at java.lang.reflect.Method.invoke(Method.java:521)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  01-30 00:34:31.772: ERROR/AndroidRuntime(497):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Line 85 is <code>l.setFocusableInTouchMode(false);</code></p>