What I would like to do is create a custom XML that will contain your preferences using the login button built in with LinearLayout. Using LinearLayout is important because the way you handle onClick events is that the lowest child with onClickListener takes precedence over the parent onClickListener. This means that the only time you call the login onClick logic is when the user directly clicks the button.
In the code, you can now extend the PreferenceFragment class, where you can configure onClick listeners and all that you may need. Please note that if you support API level 10 or lower, you may need to use it to create user preferences:
addPreferencesFromResource(R.xml.custom_preference);
Hope this is what you are looking for and I appreciate any feedback.
Rahin source share