Note that there are some explanatory texts on larger screens.

plurals
  1. PO@Override annotation error (android prefs)
    primarykey
    data
    text
    <p>When I was trying to use this code to enable preferences into my app</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.preferences); 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>An error is generated on this line</p> <pre><code> public void onCheckedChanged(CompoundButton compoundButton,boolean test) { </code></pre> <p>saying:</p> <pre><code>Multiple markers at this line - The method onCheckedChanged(CompoundButton, boolean) of type new CompoundButton.OnCheckedChangeListener(){} must override a superclass method - implements android.widget.CompoundButton.OnCheckedChangeListener.onCheckedChanged </code></pre> <p>If i remove the @Override annotation then the code doesn't work and a warning tells me that the that part of the code is not used locally.</p> <p>Having run this past someone and baffling them I was wondering if you could help?</p> <p>Are there any common scenarios that causes this error?</p> <p>I thought it might be my project set up</p> <p>Thanks </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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