I really need some help here! Logcat doesn't give out any errors, no errors in code and still nothing is happening. I got 2 normal Preferences "ueber", which works anytime I click it and "update", which is never called. I know that because i copied the exact code of "ueber" to "update" and still nothing was happening... I'm already sitting 2 weaks on that and you guys are my last hope!
preferencesettings2.xml
<PreferenceScreen>
<PreferenceCategory android:title="Info">
<Preference
android:key="update"
android:title="Update"
android:summary="Check for updates"/>
<Preference
android:key="about"
android:title="About"
android:summary="Shows information"/>
</PreferenceCategory>
</PreferenceScreen>
Preferencesettings2.java
public class Preferencesettings2 extends PreferenceActivity implements OnPreferenceClickListener {
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferencesettings2);
@Override
public boolean onPreferenceClick(Preference preference) {
if(preference.getKey().equals("update")){
download();
}else if(preference.getKey().equals("about")){
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Preferencesettings2.this);
alertDialogBuilder.setTitle("about");
alertDialogBuilder.setMessage("About");
alertDialogBuilder.setCancelable(true);
alertDialogBuilder.setNeutralButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,int which) {
dialog.cancel();
}
});
alertDialogBuilder.show();
}
return true;
}
Try locating the preference with
findPreference
and callingsetOnPreferenceClickListener
: