我正在尝试在其中创建AlertDialog
NumberPicker
但是它只显示两个分隔符而没有文本。
请参阅 http://imageshack.com/a/img673/8149/aWHQfj.png
我正在使用:
android:minSdkVersion="11"
android:targetSdkVersion="19"
码
private void showInputDialog() {
Context context = getActivity();
RelativeLayout linearLayout = new RelativeLayout(context);
final NumberPicker numberPicker = new NumberPicker(context);
numberPicker.setMaxValue(1);
numberPicker.setMinValue(100);
numberPicker.setWrapSelectorWheel(false);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(50, 50);
RelativeLayout.LayoutParams numPicerParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
numPicerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
linearLayout.setLayoutParams(params);
linearLayout.addView(numberPicker,numPicerParams);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
alertDialogBuilder.setTitle("Number of strokes");
alertDialogBuilder.setView(linearLayout);
alertDialogBuilder
.setCancelable(false)
.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
int score = numberPicker.getValue();
if (mRows != null) {
if (mClickedColIndex > 10) mClickedColIndex -= 1;
mClickedPlayer.setManualScore(mClickedColIndex, score);
} else {
if (mClickedRowIndex > 10) mClickedRowIndex -= 1;
mClickedPlayer.setManualScore(mClickedRowIndex, score);
}
mClickedText.setText(Integer.toString(score));
setupScorecard();
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
dialog.cancel();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
我已就该主题进行过多次搜索,但我还没有找到任何有效的解决方案..
还有什么我不能设置的:android:numberPickerStyle
在styles.xml中。
有人对此有任何想法吗?
答案 0 :(得分:1)
改变这个:
numberPicker.setMaxValue(1);
numberPicker.setMinValue(100);
用这个:
numberPicker.setMaxValue(100);
numberPicker.setMinValue(1);
最小值不能高于最大值。