title: if and else command in android preferences
body: <p>I've been trying to add some preferences to my app for a couple of weeks now</p>
  
  <p>I really only need the checkbox feature.</p>
  
  <p>I'm trying to control the visibility of a single radio button with the checking of a checkbox</p>
  
  <p>Here is my Preferences.java</p>
  
  <pre><code>import android.app.Activity;
  import android.content.SharedPreferences;
  import android.os.Bundle;
  import android.preference.CheckBoxPreference;
  import android.preference.Preference;
  import android.preference.PreferenceActivity;
  import android.preference.PreferenceManager;
  import android.preference.Preference.OnPreferenceClickListener;
  import android.preference.Preference.OnPreferenceChangeListener;
  import android.widget.Button;
  import android.widget.CheckBox;
  import android.widget.CompoundButton;
  import android.widget.RadioButton;
  import android.widget.Toast;
  import android.widget.CompoundButton.OnCheckedChangeListener;
  import android.view.View;
  
  
  public class Preferences extends PreferenceActivity {
  
  private RadioButton btn01;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         addPreferencesFromResource(R.xml.prefs);
         btn01 = (RadioButton)findViewById(R.id.RadioButton01);
  
         Preference customPref = (Preference) findPreference("customPref");
  
                        customPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
  
                            public boolean onPreferenceClick(Preference preference) {
                            Toast.makeText(getBaseContext(),
                                                        "The Custom Preference Has Been Clicked",
                                                        Toast.LENGTH_LONG).show();
                            SharedPreferences customSharedPreference = getSharedPreferences(
                                             "myCutomSharedPrefs", Activity.MODE_PRIVATE);
                            SharedPreferences.Editor editor = customSharedPreference
                                             .edit();
                            editor.putString("myCustomPref",
                                             "The preference has been clicked");
                            editor.commit();
                            return true;}
  
                            public void CheckBox() {
  
                            final CheckBox ThisCheckBox = (CheckBox) findViewById (R.id.checkboxPref);{   
                            ThisCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener(){
  
                                public boolean OnCheckedChange (CompoundButton compoundButton) {
                            if (ThisCheckBox.isChecked()){ 
  
                            {
                            btn01.setVisibility(0);
                            }{
  
                            btn01.setVisibility(2);
  
                            }}                                    
  }                            
  
  
  ;
  });
  
  
  };}});}}
  </code></pre>
  
  <p>Any way I'm pretty sure this is completely wrong and i get an error on this line</p>
  
  <p>ThisCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener(){</p>
  
  <p>any idea why? I think its to do with the way I've called the line above but whether I use final, boolean or void it still generates errors</p>
  
  <p>this is the error message</p>
  
  <p>The type new CompoundButton.OnCheckedChangeListener(){} must implement the inherited abstract method CompoundButton.OnCheckedChangeListener.onCheckedChanged(CompoundButton, boolean)</p>
  
  <p>So I guess what i'm asking is</p>
  
  <p>Am I doing the Preferences Right
  And how do I do the If else command properly?? </p>