【发布时间】:2013-05-22 03:19:14
【问题描述】:
我制作了一个数字选择器对话框。它看起来像左边的图像,但没有上/下箭头:
如何添加它们?
这是我的代码:
public class NumberPickerFragment extends DialogFragment
implements DialogInterface.OnClickListener {
protected final String CLS = this.getClass().getSimpleName();
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// TODO: Make this more flexible
NumberPicker np = new NumberPicker(getActivity());
np.setMaxValue(250);
np.setMinValue(100);
np.setValue(150);
np.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
np.setWrapSelectorWheel(false);
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.height)
.setView(np)
.setPositiveButton(android.R.string.ok, this)
.create();
}
@Override
public void onClick(DialogInterface dialog, int whichButton) {
// TODO: Do something with the return value
Log.d(CLS, "Received click");
}
}
【问题讨论】:
-
制作自定义号码选择器来实现这一点。
-
哦,这个没有默认值吗?我希望只在选择器上调用一个方法来添加这些箭头。
-
不,这个没有默认值..所以检查这个链接,如果它对你有帮助,那么我会把它作为答案发布..androidhub4you.com/2013/03/…
-
我提供的链接有用吗?如果可以,请接受我的回答吗?
-
这个stackoverflow.com/questions/17993192/… 可能会提供有关 NumberPicker 可以显示的每种模式的有用信息。
标签: android