PreferenceActivity in Android -


how can find if preference has been clicked , take action accordingly. in case want logout when preference in preferenceactivity key logout clicked.the following code not working.

pref.registeronsharedpreferencechangelistener(new sharedpreferences.onsharedpreferencechangelistener()     {          @override         public void onsharedpreferencechanged(sharedpreferences sharedpreferences, string key)         {             if(key.contentequals("preflogout"))             {                 toast.maketext(preferenceactivitydemoactivity.this, "logout clicked", toast.length_long).show();             }          }     }); 

xml

<preferencecategory >      <preference android:title=logout"         android:key="preflogout"/>  </preferencecategory> 

also tried using

@override public boolean onpreferenceclick(preference preference) {     if(preference.getkey().equals("preflogout"))     {         toast.maketext(preferenceactivitydemoactivity.this, "logout clicked", toast.length_long).show();     }     return false; } 

but didnt work

according xml should if(key.equals("preflogout")) {...}


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -