title: Custom PreferenceScreen with clickable buttons
body: <p>I  have created following Custom Preference Screen.
  <img src="https://i.stack.imgur.com/6uIum.png" alt="enter image description here"></p>
  
  <p>I want to add Listener on Button1 and Button2. How should I do it?</p>
  
  <p>I am using following code for creating above Preference Screen.</p>
  
  <p>DemoPref:</p>
  
  <pre><code>import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  
  public class DemoPref extends Activity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          startActivity(new Intent(this, MyPref.class));
      }
  } 
  </code></pre>
  
  <p>MyPref:</p>
  
  <pre><code>import android.os.Bundle;
  import android.preference.PreferenceActivity;
  import android.util.Log;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  
  public class MyPref extends PreferenceActivity{
      @Override
      public void onCreate(Bundle icicle) {
          super.onCreate(icicle);
          //setContentView(R.layout.tftp_setting);
          this.addPreferencesFromResource(R.xml.list_pref);
          /*Button b1 = (Button)findViewById(R.id.button1);
          b1.setOnClickListener(new OnClickListener(){
  
              @Override
              public void onClick(View v) {
  
                  Log.i("MyPref", "Button1 one is clicked.");
              }           
          });
  
          Button b2 = (Button)findViewById(R.id.button2);
          b2.setOnClickListener(new OnClickListener(){
  
              @Override
              public void onClick(View v) {
  
                  Log.i("MyPref", "Button2 one is clicked.");
              }           
          });*/
      }
  }
  </code></pre>
  
  <p>res\layout\setting.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
     android:orientation="vertical"
    &gt;
    &lt;LinearLayout  android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"&gt;
  
      &lt;TextView android:text="TextView1" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/TextView&gt;
      &lt;EditText android:text="EditText2" android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/EditText&gt;
  
    &lt;/LinearLayout&gt;
  
    &lt;LinearLayout  android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"&gt;
  
      &lt;TextView android:text="TextView2" android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/TextView&gt;
      &lt;EditText android:text="EditText2" android:id="@+id/editText2" android:layout_height="wrap_content" android:layout_width="wrap_content"&gt;&lt;/EditText&gt;
  
    &lt;/LinearLayout&gt;
  
     &lt;LinearLayout  android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"&gt;
  
      &lt;Button android:text="Button1" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/Button&gt;
      &lt;Button android:text="Button2" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/Button&gt;
  
     &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>res\xml\pref.xml:</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;PreferenceScreen  android:title="My Setting"  android:layout="@layout/setting" android:summary="This is my setting."&gt;&lt;/PreferenceScreen&gt;
  
  &lt;/PreferenceScreen&gt;
  </code></pre>