我有一个Preference活动,它使用我的XML文件定义的List Preferences.如何将列表活动的摘要设置为所选的值?
谢谢!
我正在尝试在我的首选项屏幕中创建一个NumberPicker对话框.我已经在此之后做了一个:https://stackoverflow.com/a/5533295/2442638
但是,对于我的第二个对话框,我只想要一个微调器,所以我调整了代码如下:
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= null;
public static int getMinute(String time) {
String[] pieces = time.split(":");
return (Integer.parseInt(pieces[1]));
}
public SnoozeTPP(Context context, AttributeSet attrs) {
super(context, attrs);
setPositiveButtonText("Set");
setNegativeButtonText("Cancel");
}
@Override
protected View onCreateDialogView() {
np = new NumberPicker(getContext());
return (np);
}
@Override
protected void onBindDialogView(View v) {
super.onBindDialogView(v);
np.setMaxValue(60);
np.setValue(Minute);
} …
Run Code Online (Sandbox Code Playgroud)