title: Custom ListView Inside ListFragment
body: <p>I am trying to use the ListFragment and assign an adapter to it.
  I tried many different methods, but still the app crashes and won't start.</p>
  
  <p>Here is what I have done:</p>
  
  <p>fragment_five.xml:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity"
      android:background="@drawable/bg11"&gt;
  
      &lt;ListView
          android:id="@android:id/list"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
      &lt;/ListView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>FiveFragment.java:</p>
  
  <pre><code>import android.os.Bundle;
  import android.support.v4.app.ListFragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  
  public class FiveFragment extends ListFragment {
  
      public FiveFragment() {
  
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          return inflater.inflate(R.layout.fragment_five, container, false);
      }
  
      @Override
      public void onActivityCreated(Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
  
          String items[] = getResources().getStringArray(R.array.list5);
  
          CustomListAdapter adapter = new CustomListAdapter(getActivity().getBaseContext(), items);
          //ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;&gt;(getActivity(), android.R.layout.simple_list_item_1, items);
  
          setListAdapter(adapter);
      }
  
      @Override
      public void onListItemClick(ListView l, View v, int position, long id) {
  
      }
  
  
  }
  </code></pre>
  
  <p>and here is the CustomListAdapter that I am using... I am sure it works cause I have tested elsewhere</p>
  
  <pre><code>import android.content.Context;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.TextView;
  
  public class CustomListAdapter extends BaseAdapter {
  
      private Context context;
      private String texts[];
  
      public CustomListAdapter(Context context, String[] texts) {
          this.context = context;
          this.texts = texts;
      }
  
      @Override
      public int getCount() {
          return texts.length;
      }
  
      @Override
      public Object getItem(int position) {
          return position;
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      static class ViewHolder {
          private TextView details;
      }
  
      @Override
      public View getView(final int position, View convertView, ViewGroup parent) {
          View rowView = convertView;
  
          if (rowView == null) {
              LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              rowView = inflater.inflate(R.layout.list_item, parent, false);
  
              ViewHolder viewHolder = new ViewHolder();
              viewHolder.details = (TextView) rowView.findViewById(R.id.details);
  
              rowView.setTag(viewHolder);
          }
  
          ViewHolder holder = (ViewHolder) rowView.getTag();
          holder.details.setText(texts[position]);
  
          return rowView;
      }
  }
  </code></pre>
  
  <p>When I use the simple ArrayAdapter everything is ok but when I use the Custom Adapter the app crashes... it doesn't matter that which adapter I use either the CustomArrayAdapter or the CustomBaseAdapter it just doesn't work.</p>
  
  <p>If you know any way around this please help!</p>