dialog-preference

Yes or No confirmation in Android Preferences [duplicate]

笑着哭i 提交于 2020-01-05 03:25:33
问题 This question already has answers here : How to implement a confirmation (yes/no) DialogPreference? (3 answers) Closed 5 years ago . 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 someone please help me out? I'm a beginner, ideas or even code would be very helpful, thank you. 回答1: I used a simple

Yes or No confirmation in Android Preferences [duplicate]

那年仲夏 提交于 2020-01-05 03:24:09
问题 This question already has answers here : How to implement a confirmation (yes/no) DialogPreference? (3 answers) Closed 5 years ago . 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 someone please help me out? I'm a beginner, ideas or even code would be very helpful, thank you. 回答1: I used a simple

Formatted value of NumberPicker disappears onClick

心不动则不痛 提交于 2020-01-04 09:17:45
问题 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() { @Override public String format(int value) { return TextUtils.makeQuatityString(getContext(), value, R.plurals.nWeek); } }); Example output: 4 Weeks, where 4 is the value. The NumberPicker is in a Dialog and after a short click on the value, the "Weeks"

Appcompatactivity with custom native (not compatibility) dialogpreference containing a TimePicker

断了今生、忘了曾经 提交于 2019-12-24 10:36:41
问题 I am building a preferences / settings screen inside an Android AppCompatActivity . One requirement is a custom [DialogPreference][1] with a TimePicker . The DialogPreference must be 'native', meaning not the compatibility version like described here and here. The code for the AppCompatActivity: ... public class SettingsActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity

Create NumberPicker dialog in preference

霸气de小男生 提交于 2019-12-19 02:18:43
问题 I am trying to create a NumberPicker dialog in my preference screen. I have already made one following this:https://stackoverflow.com/a/5533295/2442638 However, for my second dialog, I only want one spinner, so I have adapted the code as follows: import android.content.Context; import android.content.SharedPreferences; import android.content.res.TypedArray; import android.preference.DialogPreference; import android.util.AttributeSet; import android.view.View; import android.widget

onUserInteraction not working in DialogPreference

这一生的挚爱 提交于 2019-12-18 06:23:20
问题 It is expected that onUserInteraction is being called for any user interaction. it works fine in PreferenceActivity . However, when a DialogPreference is popup, onUserInteraction is not called anymore even there is user interaction such as touch event. It seems that DialogPreference is not the only case. Whenever Dialog is shown, it does not report the user interaction to activity. But what can I do if I really need it. Thank You. 回答1: As far as I know, the onUserInteraction() is simply not

Why won't Fragment retain state when screen is rotated?

你说的曾经没有我的故事 提交于 2019-12-17 17:30:48
问题 I've been having some trouble getting some custom DialogPreference subclasses inside a PreferenceFragment to remain visible when the screen is rotated. I don't experience this problem when using a PreferenceActivity, so I don't know whether it's an Android bug or a problem with my code, but I'd like someone to confirm whether they are having the same experience. To test this, first create a preference screen containing at least one DialogPreference (it doesn't matter which subclass). Then

Why custom DialogPreference doesnt trigger on onSharedPreferenceChanged listener?

眉间皱痕 提交于 2019-12-06 04:42:38
问题 I am trying to make dialog preference in preferences, where user just click positive button to trigger some action. (Clear database? No | Yes) public class MyDialogPreference extends DialogPreference { public MyDialogPreference(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } @Override protected void onDialogClosed(boolean positiveResult) { super.onDialogClosed(positiveResult); Log.d(MainActivity.TAG, "# onDialogClosed: " + positiveResult

Why custom DialogPreference doesnt trigger on onSharedPreferenceChanged listener?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 10:53:01
I am trying to make dialog preference in preferences, where user just click positive button to trigger some action. (Clear database? No | Yes) public class MyDialogPreference extends DialogPreference { public MyDialogPreference(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } @Override protected void onDialogClosed(boolean positiveResult) { super.onDialogClosed(positiveResult); Log.d(MainActivity.TAG, "# onDialogClosed: " + positiveResult); } } I dont actually want to persist anything, just trigger onSharedPreferenceChanged listener, so I

Create NumberPicker dialog in preference

♀尐吖头ヾ 提交于 2019-11-30 19:46:27
I am trying to create a NumberPicker dialog in my preference screen. I have already made one following this: https://stackoverflow.com/a/5533295/2442638 However, for my second dialog, I only want one spinner, so I have adapted the code as follows: import android.content.Context; import android.content.SharedPreferences; import android.content.res.TypedArray; import android.preference.DialogPreference; import android.util.AttributeSet; import android.view.View; import android.widget.NumberPicker; public class SnoozeTPP extends DialogPreference { private int Minute = 0; private NumberPicker np=