title: How to Create a Custom SeekBar Preference?
body: <p>I'm trying to create a custom seekbar preference, but Android can't seem to find the element. I get</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setVisibility(int)' on a null object reference at
      at android.support.v7.preference.SeekBarPreference.onBindViewHolder(SeekBarPreference.java:154)
  </code></pre>
  
  <p>when I try to access the setting. The reason seems to be that it can't find my custom seekbar element and link it to the preference. Usually I would name the custom preference element something like <code>@android:id/seekbar</code> to make the linkage work, but when it comes to SeekBar, it says that's private. I tried <code>@+id/seekbar</code> as per <a href="https://stackoverflow.com/questions/16108609/android-creating-custom-preference/16109063">Android: Creating custom preference</a>, but it doesn't seem to work to tie my custom seekbar to the preference.</p>
  
  <p>Here is my code:</p>
  
  <p><strong>Preference XML</strong></p>
  
  <pre><code>&lt;android.support.v7.preference.SeekBarPreference
              android:key="my_seekbar_preference"
              android:layout="@layout/seekbar_preference"
              android:max="10"
              android:defaultValue="5" /&gt;
  </code></pre>
  
  <p><strong>SeekBar Layout</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:orientation="vertical"
  android:layout_margin="@dimen/half_normal"&gt;
  
  &lt;TextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_margin="@dimen/half_normal"
      android:layout_marginLeft="@dimen/normal"
      style="@style/SettingsSubHeader"
      android:text="Seekbar Settings"/&gt;
  
  &lt;SeekBar
      android:id="@+id/seekbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      style="@style/Widget.AppCompat.SeekBar.Discrete"
      android:max="10"
      android:min="0"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Any ideas on what I'm doing wrong? I don't this problem with any of my other custom preferences.</p>