title: How to add a button to a PreferenceScreen?
body: <p>I'm quite new to Android Development and just came across Preferences.
  I found <code>PreferenceScreen</code> and wanted to create a login functionality with it. The only problem I have is that I don't know how I could add a &quot;Login&quot; button to the <code>PreferenceScreen</code>.</p>
  <p>Here's what my <code>PreferenceScreen</code> looks like:</p>
  <pre><code>&lt;PreferenceScreen xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
  ...
      &lt;PreferenceScreen android:title=&quot;@string/login&quot; android:key=&quot;Login&quot;&gt;
          &lt;EditTextPreference android:persistent=&quot;true&quot; android:title=&quot;@string/username&quot; android:key=&quot;Username&quot;&gt;&lt;/EditTextPreference&gt;
          &lt;EditTextPreference android:title=&quot;@string/password&quot; android:persistent=&quot;true&quot; android:password=&quot;true&quot; android:key=&quot;Password&quot;&gt;&lt;/EditTextPreference&gt;
      &lt;/PreferenceScreen&gt;
  ...
  &lt;/PreferenceScreen&gt;
  </code></pre>
  <p>The Button should be right under the two <code>EditTextPreference</code>s.</p>
  <p>Is there a simple solution for this problem? The one solution I found was not working because I use sub <code>PreferenceScreen</code>s.</p>
  <h3>Update:</h3>
  <p>I figured out that i can add buttons this way:</p>
  <pre><code>&lt;PreferenceScreen android:title=&quot;@string/login&quot; android:key=&quot;Login&quot;&gt;
          &lt;EditTextPreference android:persistent=&quot;true&quot; android:title=&quot;@string/username&quot; android:key=&quot;Username&quot;&gt;&lt;/EditTextPreference&gt;
          &lt;EditTextPreference android:title=&quot;@string/password&quot; android:persistent=&quot;true&quot; android:password=&quot;true&quot; android:key=&quot;Password&quot;&gt;&lt;/EditTextPreference&gt;
          &lt;Preference android:layout=&quot;@layout/loginButtons&quot; android:key=&quot;loginButtons&quot;&gt;&lt;/Preference&gt;
  &lt;/PreferenceScreen&gt;
  </code></pre>
  <p>and the layout file (<code>loginButtons.xml</code>) looks that way:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_width=&quot;fill_parent&quot;
      android:weightSum=&quot;10&quot; 
      android:baselineAligned=&quot;false&quot; android:orientation=&quot;horizontal&quot;&gt;
      &lt;Button android:text=&quot;Login&quot; android:layout_width=&quot;fill_parent&quot;
          android:layout_weight=&quot;5&quot; android:layout_height=&quot;wrap_content&quot;
          android:id=&quot;@+id/loginButton&quot; android:layout_gravity=&quot;left&quot;&gt;&lt;/Button&gt;
      &lt;Button android:text=&quot;Password?&quot; android:layout_width=&quot;fill_parent&quot;
          android:layout_weight=&quot;5&quot; android:layout_height=&quot;wrap_content&quot;
          android:id=&quot;@+id/forgottenPasswordButton&quot;&gt;&lt;/Button&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>So now the buttons appear but I can't access them in code.
  I tried it with <code>findViewById()</code> but this is returning null. Any ideas how I could access these buttons?</p>