title: custom row in a listPreference?
body: <p>I am trying to create a <code>ListPreference</code> but somehow disable one of the items. Sort of like gray it out or something and not have the ability to choose it. It will be an upcoming feature and I want it to be in the list just not selectable.</p>
  
  <p>I have created a custom <code>ListPreference</code> class and in that class a custom adapter, hoping to use the adapter to create what I want.</p>
  
  <p>The code works, and it sets the adapter, but none of the adapter functions get called. I set breakpoints on the methods, such as <code>getCount()</code> but they never get called.</p>
  
  <p>Here's my code. Custom ListPreference taken from <a href="http://blog.350nice.com/wp/archives/240" rel="nofollow noreferrer">http://blog.350nice.com/wp/archives/240</a></p>
  
  <pre><code>import android.content.Context;
  import android.content.DialogInterface;
  import android.graphics.Color;
  import android.preference.ListPreference;
  import android.util.AttributeSet;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.app.AlertDialog.Builder;
  
  public class CustomListPreference extends ListPreference {
  
      private boolean[] mClickedDialogEntryIndices;
      CustomListPreferenceAdapter customListPreferenceAdapter = null;
      Context mContext;
  
      public CustomListPreference(Context context, AttributeSet attrs) {
          super(context, attrs);
          mContext = context;
          mClickedDialogEntryIndices = new boolean[getEntries().length];
      }
  
      @Override
      protected void onPrepareDialogBuilder(Builder builder) {
          CharSequence[] entries = getEntries();
          CharSequence[] entryValues = getEntryValues();
          if (entries == null || entryValues == null
                  || entries.length != entryValues.length) {
              throw new IllegalStateException(
                      "ListPreference requires an entries array "
                      +"and an entryValues array which are both the same length");
          }
          builder.setMultiChoiceItems(entries, mClickedDialogEntryIndices,
                  new DialogInterface.OnMultiChoiceClickListener() {
  
                      public void onClick(DialogInterface dialog, int which,
                              boolean val) {
                          mClickedDialogEntryIndices[which] = val;
                      }
                  });
          // setting my custom list adapter
          customListPreferenceAdapter = new CustomListPreferenceAdapter(mContext);
          builder.setAdapter(customListPreferenceAdapter, null);
      }
  
      private class CustomListPreferenceAdapter extends BaseAdapter {
  
          public CustomListPreferenceAdapter(Context context) {}
  
          public int getCount() {
              return 1;
          }
  
          public Object getItem(int position) {
              return position;
          }
  
          public long getItemId(int position) {
              return position;
          }
  
          public View getView(int position, View convertView, ViewGroup parent) {
              convertView.setBackgroundColor(Color.BLUE);
              return convertView;
          }
      }
  }
  </code></pre>