title: Android: listview: custom items: nullpointerexception, findviewbyid returns null
body: <p>I have been googling and searching to resolve this error for some time and I can`t seem to find out why and how to solve it.</p>
  
  <p>I`m using a customAdapter to fill in my listview. I inflate the xml describing my listItem. I make viewHolder object and load in my textview using findViewById. After that i want to set the text of that textview but it findViewbyid returns a null value. So automaticcally resolving into a nullpointerexception.</p>
  
  <p>Adapter:</p>
  
  <pre><code>/** CLASS : Custom Adapter for the listview */
  private class CustomAdapter extends ArrayAdapter&lt;Track&gt;{
      private List&lt;Track&gt; items;
      private Context mContext;
      private int layoutResourceId;       
      private ViewHolder mHolder;
  
      public CustomAdapter(Context context, int layoutId, List&lt;Track&gt; objects) {
          super(context, layoutId, objects);
          layoutResourceId=layoutId;
          items = objects;
          mContext=context;       
      }       
  
      public View getView(int position, View convertView, ViewGroup parent) {
           if(convertView == null){
               LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
               convertView = inflater.inflate(layoutResourceId, parent, false);
               mHolder = new ViewHolder();
               ****** RETURNS NULL DURING DEBUGGING ******
               mHolder.textViewCenter = (TextView)findViewById(R.id.textview_list_item_central);
               convertView.setTag(mHolder);
           }else{
               mHolder = (ViewHolder) convertView.getTag();
           }
           Track track = items.get(position);
           ****** ERROR HAPPENS HERE ******
           mHolder.textViewCenter.setText(track.getTrack());
           return convertView;
      }
  
      class ViewHolder{
          ImageView imageView;
          TextView textViewCenter;
          TextView textViewRight;
      }
  }
  </code></pre>
  
  <p>XML:</p>
  
  <pre><code>?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal" &gt;
  
  &lt;ImageView
      android:id="@+id/imageview_list_albumart_icon"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="left"
      android:src="@drawable/ic_music" /&gt;
  
  &lt;TextView
      android:id="@+id/textview_list_item_central"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:layout_weight="0.5"
      android:text="Center"
      android:textSize="20sp" &gt;
  &lt;/TextView&gt;
  
  &lt;TextView
      android:id="@+id/textview_list_item_right"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="right"
      android:paddingRight="10dip"
      android:text="Right" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Any help is appreciated!</p>