title: How can I launch a event when I check or uncheck CheckBoxPreference in PreferenceScreen?
body: <p>I hope to execute a function when I check or uncheck CheckBoxPreference in PreferenceScreen, how can I do ? Thanks!</p>
  
  <pre><code>&lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
      android:key="AppPreference"
      android:summary="@string/PreferenceSummary"
      android:title="@string/Preference" &gt;
  
       &lt;CheckBoxPreference
          android:defaultValue="true"
          android:key="AlwaysHideIcon"
          android:title="@string/AlwaysHideIconTitle"
          android:summary="@string/AlwaysHideIconSummary"  
          android:layout="@layout/sms_custom_preference_layout"  
       /&gt;   
  
  &lt;/PreferenceScreen&gt;
  
  public class SmsPreference extends PreferenceActivity{
       @Override
       protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);         
              addPreferencesFromResource(R.xml.smspreference);
              setContentView(R.layout.sms_custom_preference);
  
              // Look up the AdView as a resource and load a request.
              if (PublicPar.IsRegistered==false) {
                  AdView adView = (AdView)this.findViewById(R.id.adView);
                  adView.loadAd(new AdRequest());
              }
  
  
              Button btnClose=(Button)findViewById(R.id.btnClosePreference);
              btnClose.setOnClickListener(new OnClickListener(){
                  @Override
                  public void onClick(View v) {
                      // TODO Auto-generated method stub
                      finish();
                  }           
              });
  
       }
  
  }
  
  &lt;RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"   
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/border_ui"
    android:orientation="vertical"&gt;        
  
      &lt;ListView android:id="@android:id/list"
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content"
          android:layout_below="@+id/adView"    
          android:layout_above="@+id/linearLayout1"
          &gt;        
      &lt;/ListView&gt; 
  
      &lt;LinearLayout
          android:id="@+id/linearLayout1"  
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_gravity="center_vertical"
          android:gravity="center"
          android:orientation="horizontal"
          android:weightSum="4" &gt;
  
          &lt;Button
              android:id="@+id/btnClosePreference"
              style="@style/myTextAppearance"
              android:layout_width="0dip"
              android:layout_height="fill_parent"
              android:layout_weight="1"
              android:layout_gravity="center"
              android:text="@string/BtnReturn" &gt;
          &lt;/Button&gt;
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>