title: Get View from custom Preference
body: <p>In my app I have a PreferenceScreen which looks like this:</p>
  
  <pre><code>&lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" &gt;
      &lt;CheckBoxPreference
              android:key="state"
              android:title="@string/stateTitle"
              android:summary="@string/stateSummary"
              android:defaultValue="false" /&gt;
  
      &lt;Preference
              android:key="test"
              android:layout="@layout/pref_control"
              android:dependency="state" /&gt;
  &lt;/PreferenceScreen&gt;
  </code></pre>
  
  <p>Now my question is how can I get the views which are in my <code>pref_control.xml</code> from the PreferenceActivity? I tried with normal <code>findViewById()</code> but that ends in a NullPointerException. Here is my code that causes the exception:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      addPreferencesFromResource(R.xml.preferences);
  
      ((Button) findViewById(R.id.startTime)).setText("bla");
      ((Button) findViewById(R.id.endTime)).setText("bla");
  }
  </code></pre>