In my Android app I want to show a Dialog if the user selects on something that looks like plain text in a PreferenceScreen. I have seen How to open AlertDialog from preference screen?, but that solution launches from a CheckBoxPreference.
In my case, I'd like to launch from something that looks like a TextView (or I suppose it could be a button), and it would then lead to an "About" dialog I already have. Any suggestions how to do that? Thanks.
preferences.xml file:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference android:key="dialog_preference" />
</PreferenceScreen>
Activity:
addPreferencesFromResource(R.xml.preferences);
dialogPreference = (Preference) getPreferenceScreen().findPreference("dialog_preference");
dialogPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
// dialog code here
return true;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With