Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think the signature of the method you are trying to override is incorrect. Replace this:</p> <pre><code>public boolean OnCheckedChange (CompoundButton compoundButton) { </code></pre> <p>with this:</p> <pre><code>@Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { </code></pre> <p><strong>EDIT</strong> Ok, here's an attempt to fix the whole class. Backup your current code, then select all the code below, and copy it. Select all of the code in your class and replace it with this:</p> <pre><code>import android.app.Activity; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.Preference.OnPreferenceClickListener; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.RadioButton; import android.widget.Toast; import android.widget.CompoundButton.OnCheckedChangeListener; 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(){ @Override public void onCheckedChanged(CompoundButton compoundButton,boolean test) { if (ThisCheckBox.isChecked()){ btn01.setVisibility(0); } else { btn01.setVisibility(2); } } }); }; }); } } </code></pre> <p>The above code compiles with no issues for me in eclipse</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload