Questions tagged [dialog-preference]

A class in the Android preferences framework that allows applications to implement custom user interfaces for editing a preference setting.

A class in the Android preferences framework that allows applications to implement custom user interfaces for editing a preference setting.

A very useful guide for writing DialogPreference implementations can be found in this answer: Concise way of writing new DialogPreference classes?

67 questions
4
votes
1 answer

How to run function in Preference class from PreferenceActivity

There are only so many types of Preference types we can set in PreferenceActivity. I am trying to run a specific function once a certain preference is clicked. Is there a way to override a preferenceScreen or editText onClick?
3
votes
2 answers

PreferenceDialog in PreferenceActivity - Target fragment must implement TargetFragment interface

I'm trying to implement a DialogPreference in a Preference activity. I achieved it but it seems setTargetFragment is marked as deprecated. Here is my old code: override fun onDisplayPreferenceDialog(preference: Preference?) { val…
Clandes
  • 61
  • 2
  • 7
3
votes
1 answer

Formatted value of NumberPicker disappears onClick

My NumberPicker in setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS) mode and the setWrapSelectorWheel(false) is turned off. I formatted my Numberpicker with a simple formatter: mNumberPicker.setFormatter(new NumberPicker.Formatter() { …
3
votes
3 answers

Using a NumberPicker as a DialogPreference. Why won't my setting save?

just learning android code here. I'm not sure what I'm missing, but I'm trying to create a custom DialogPreference that uses a NumberPicker which will let the user choose the year. I've tried to follow android's Settings Guide, but my chosen value…
NSouth
  • 5,067
  • 7
  • 48
  • 83
3
votes
2 answers

Yes or No confirmation in Android Preferences

I need to implement a "Reset" option in Settings. When the setting is clicked, a simple dialog should open asking to confirm. I've taken a look at DialogPreference but I can't seem to be able to find a good solution, or tutorials anywhere. Can…
Vedavyas Bhat
  • 2,068
  • 1
  • 21
  • 31
3
votes
1 answer

Refresh DialogPreference without closing PreferenceActivity

I have a PrefrenceActivity which includes DialogPreference with my custom layout (edittext and checkbox). When my DialogPrefernce is called for the first time, its onSetInitValue is called, I get values from SharedPreferences and then in…
Petr B
  • 519
  • 2
  • 6
  • 15
3
votes
2 answers

Cannot launch DialogPreference programmatically (Null Pointer Exception thrown)

I have a custom class that extends DialogPreference. It works perfectly if launched from the Preference menu. I want to be able to launch it from an Activity as well. Below is my DialogPreference class in which I exposed the showDialog() method…
Mike Szczys
  • 125
  • 1
  • 10
2
votes
0 answers

Implementing onSetInitialValue with null pointer exception in DialogPreference

I want to implement a TimePreference using DialogPreference, I found a good tutorial to do that here after implementing the TimePreference I noticed the onSetInitialValue(bool,Object) was deprecated and I implemented instead…
Anton Makov
  • 825
  • 2
  • 9
  • 25
2
votes
1 answer

Using support library v4 fragments in custom DialogPreference

I'm trying to implement custom DialogPreference, whose layout will use fragments. An app should support API 10 (which does not natively support fragments). In order to work with fragments I need to get an instance of the…
2
votes
1 answer

Adding custom DialogPreference to xml file

I've implemented this custom DialogPreference in C# with Xamarin however I'm having issues adding it to my xml file. namespace Client.Android { public class TimePreference : DialogPreference { private int lastHour = 0; private int lastMinute…
2
votes
1 answer

DialogPreference.onDialogClosing(boolean) always receive positiveResult == false

I'm first using Android Preferences and encountered unexpected problem. I'm extend DialogPreference class and all works fine except one thing: in method onDialogClosing(boolean positiveResult) I'm receiving false no matter what button I'v…
2
votes
1 answer

Retrieve value from Custom DialogPreference and persist value

Trying to write a custom dialog preference (a NumberPickerDialog). Although the android documentation details on this topic, I seem to miss some essential building blocks in their documentation. What I have so far is a custom preference dialog that…
bas
  • 13,550
  • 20
  • 69
  • 146
2
votes
1 answer

How to disable outside touching to hide DialogPreference

i'm developing a custom DialogPreference. When user clicks outside the dialog, it is cancelled and i need to avoid this. I know that Dialog has method setCanceledOnTouchOutside(boolean cancel) that is what i need but the DialogPreference not. in…
Jayyrus
  • 12,961
  • 41
  • 132
  • 214
2
votes
1 answer

Should I use Dialog or DialogPreference to make a specialized preference dialog?

I'm trying to make a custom setting in my application's PreferenceActivity that brings up a Dialog which will ultimately have the following An EditText to specify a server A Button for testing the server connection A response Icon specifying if the…
Robin Newhouse
  • 2,158
  • 2
  • 19
  • 17
2
votes
2 answers

Android DialogPreference Layout TextSize

I'm using a PreferenceScreen with some different preferences. I'm also using a custom preference extending DialogPreference. Now the fontsize of the custom DialogPreference is different than the font size of the other preferences. I tried to apply a…
andineupert
  • 341
  • 2
  • 6
  • 19