问题描述
我做了一个numberpicker对话框。它看起来像在左侧的图像,但没有向上/向下箭头:
我如何添加它们?
下面是我的code:
公共类NumberPickerFragment扩展DialogFragment
实现DialogInterface.OnClickListener { 保护最后弦乐CLS = this.getClass()getSimpleName()。 @覆盖
公共对话框onCreateDialog(捆绑savedInstanceState){
// TODO:让这个更灵活
NumberPicker NP =新NumberPicker(getActivity());
np.setMaxValue(250);
np.setMinValue(100);
np.setValue(150);
np.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
np.setWrapSelectorWheel(假); 返回新AlertDialog.Builder(getActivity())
.setTitle(R.string.height)
.setView(NP)
.setPositiveButton(android.R.string.ok,这一点)
。创建();
} @覆盖
公共无效的onClick(DialogInterface对话,诠释whichButton){
// TODO:做一些与返回值
Log.d(CLS,收到点击);
}
}
在Android上,NumberPicker有两种口味 - 一个用上下键和其他与车轮的滚动实施。
根据您当前的主题,NumberPicker是psented用户$ P $。
来源:
另外,如果你看看NumberPicker源$ C $ C,向上/向下ImageButtons才有效,如果NumberPicker布局,由您主题的样式定义等于默认R.layout.number_picker
I've made a numberpicker dialog. It looks like the image on the left, but without the up/down arrows:
How can I add them?
Here's my code:
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");
}
}
In Android, NumberPicker has two flavours - One with up down button and other with wheel scroll implementation.
Depending on the your current theme, NumberPicker is presented to the user.
Source: http://developer.android.com/reference/android/widget/NumberPicker.html
Also, if you look into the source code of NumberPicker, up/down ImageButtons are only enabled if NumberPicker layout, as defined by your Theme's style is equal to default R.layout.number_picker
这篇关于添加上/下箭头到Android numberpicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!