title: Programmatically Creating ListPreference - But Entry List is Empty
body: <p>I'm trying to programmatically create a <code>ListPreference</code>, which I can do but when I select it, it's list of entries is empty. I believe I am correctly setting the <code>setEntries()</code> and <code>setEntryValues()</code> with <code>CharSequence</code> arrays, but it's just empty when I select it. </p>
  
  <p>Please find below the <code>ActivitySetting</code> class. Please note I'm using <code>PreferenceFragments</code> as to not use deprecated methods. But I only have one <code>PreferenceFragment</code> which is currently set as default</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
  
      // Display the fragment as the main content.
      getFragmentManager().beginTransaction().replace(android.R.id.content, new PrefsFragment()).commit();
  }
  
  public static class PrefsFragment extends PreferenceFragment
  {
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
  
          // Load the preferences from an XML resource
          addPreferencesFromResource(R.xml.settings);
  
          // Create the new ListPref
          ListPreference customListPref = new ListPreference(getActivity());
  
          // Get the Preference Category which we want to add the ListPreference to
          PreferenceCategory targetCategory = (PreferenceCategory) findPreference("TARGET_CATEGORY");
  
           CharSequence[] entries = new CharSequence[]{"One", "Two", "Three"};
           CharSequence[] entryValues = new CharSequence[]{ "1", "2", "3" };
  
           // IMPORTANT - This is where set entries...looks OK to me
           customListPref.setEntries(entries);
           customListPref.setEntryValues(entryValues);
  
           customListPref.setTitle("Title");
           customListPref.setSummary("This is the summary");
           customListPref.setDialogMessage("Dialog Message");
           customListPref.setPersistent(true);
  
           // Add the ListPref to the Pref category
           targetCategory.addPreference(customListPref);
      }
   }
  }
  </code></pre>
  
  <p>Here is the Setting.xml it just has the single <code>PreferenceCategory</code> which the <code>ListPreference</code> is added to:</p>
  
  <pre><code>   &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" &gt;
      &lt;PreferenceCategory android:title="Some Options" android:key="TARGET_CATEGORY"&gt;
      &lt;/PreferenceCategory&gt;
  &lt;/PreferenceScreen&gt;
  </code></pre>
  
  <p>Here is what I get. The <code>ListPreference</code> has been successfully but when I select it.... No entries :(  I'm expecting the options:  "One", "Two", "Three"</p>
  
  <p><img src="https://i.stack.imgur.com/r8rM4.png" alt="enter image description here"></p>