What I’m trying to implement is basically and exact replica of the image below (the preferences that I’ve squared). Pressing anything to the left of the preference should open up a dialog. Pressing the togglebutton will disable/enable whatever I’m setting in this preference.
I’ve been trying for hours now and I’ve come up empty-handed. How do I implement this in a PreferenceActivity?

EDIT: It seems people are misunderstanding my question. It is very important that I figure out how to solve my problem using a PreferenceActivity. NOT an Activity. I don’t care whether I need to do it in XML or programatically. Just please refrain from providing me with answers that I cannot use within a or something similar.
EDIT 2 : Added a bounty – I really need an answer to this
Hell man, I like your idea 🙂
This is just same as @MH’s answer, but more concise.
I tested with
ToggleButton, notSwitch.And the
preferences.xml:EncryptorEditTextPreferenceis not related to your question, but it uses same technique (extendingEditTextPreference).