title: Making my `CustomDialogFragment` generic
body: <p>So i want to make my <code>CustomArrayAdapter</code> class generic.</p>
  
  <p>CustomDialogFragmentNotGeneric:</p>
  
  <pre><code>public class CustomDialogFragment extends DialogFragment
  {
      TextView listViewItemTextView;
      ArrayAdapter&lt;String&gt; arrayAdapter;
      ListView dialogListView;
      String[] items = {"Hello","Hello there","Hi","Hi there"};
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
      {
          View rootView = inflater.inflate(R.layout.dialog, container,false);
  
          getDialog().setTitle("Choose an option"); // Set dialog title
  
          listViewItemTextView = (TextView) rootView.findViewById(R.id.list_view_item_text_view_id);
          dialogListView = (ListView) rootView.findViewById(R.id.dialog_list_view_id);
  
          getDialog().setTitle("Opening Words"); // Setting dialog title
  
  
          CustomArrayAdapter customArrayAdapter = new CustomArrayAdapter(getActivity(), items);
          dialogListView.setAdapter(customArrayAdapter);
  
          dialogListView.setOnItemClickListener(new OnItemClickListener() 
          {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view,int position, long id)
              {
                  Toast.makeText(getActivity(), items[position], Toast.LENGTH_SHORT).show();
              }
          });
  
          return rootView;
      }
  }
  </code></pre>
  
  <p>It's not generic because of the <code>String[] itemm =</code> line.
  So instead of building <em>a lot</em> of classes that in each there will be a different <code>String[] item</code>, how do i make that generic?</p>
  
  <p>dialog.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;ListView 
      android:id="@+id/dialog_list_view_id"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      /&gt;
  </code></pre>
  
  <p></p>
  
  <p>MyCustomArrayAdapter class:</p>
  
  <pre><code>package com.example.predesignedmails;
  
  import android.content.Context;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.TextView;
  
  public class CustomArrayAdapter extends ArrayAdapter&lt;String&gt;
  {
      Context context;
      String[] items;
      LayoutInflater layoutInflater;
  
      public CustomArrayAdapter(Context context, String[] items) 
      {
          super(context, R.layout.list_view_row,items);
  
          this.context = context;
          this.items = items;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent)
      {
          if (convertView == null)
          {
              this.layoutInflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = this.layoutInflater.inflate(R.layout.list_view_row,parent,false);
          }
  
          TextView rowTextView = (TextView) convertView.findViewById(R.id.row_text_view_id);
  
          rowTextView.setText(this.items[position]);
  
          return convertView;
      }
  }
  </code></pre>
  
  <p>list_view_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="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
  &lt;TextView
      android:id="@+id/row_text_view_id"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I have put a lot of effort into this post. Please help me guys. Thanks.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>my activity layout:</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"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="com.example.predesignedmails.LoveMailsActivity" &gt;
  
  &lt;TextView
      android:id="@+id/love_email_emai_to_send_to_text_view_id"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="@string/emai_to_send_to_text_view_text"
      android:textSize="16sp"
      android:textStyle="bold"
      android:textColor="@color/opening_words_list_view_header_color"
      /&gt;
  
  &lt;EditText
      android:id="@+id/love_email_email_to_send_to_edit_text_id"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:hint="@string/emai_to_send_to_edit_text_hint"
      android:inputType="textEmailAddress"
      android:textSize="18sp"
      android:textColor="@color/selection_text_color"
      android:layout_below="@id/love_email_emai_to_send_to_text_view_id"
      /&gt;
  
  &lt;TextView
      android:id="@+id/love_email_opening_words_header_text_view_id"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="@string/love_email_opening_words_text_view_text"
      android:textSize="16sp"
      android:textStyle="bold"
      android:textColor="@color/opening_words_list_view_header_color"
      android:layout_below="@id/love_email_email_to_send_to_edit_text_id"
      /&gt;
  
  &lt;TextView
      android:id="@+id/love_email_opening_words_text_view_id"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="@string/initial_text"
      android:textSize="18sp"
      android:textColor="@color/selection_text_color"
      android:layout_below="@id/love_email_opening_words_header_text_view_id"
      /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>