首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NumberPicker没有显示数字

NumberPicker没有显示数字
EN

Stack Overflow用户
提问于 2014-12-23 11:35:49
回答 1查看 1.8K关注 0票数 1

我试图创建一个AlertDialog,里面有一个NumberPicker

但是,它只显示两个分隔符,而不显示文本。

请参阅http://imageshack.com/a/img673/8149/aWHQfj.png

我正在使用:

代码语言:javascript
复制
android:minSdkVersion="11"
android:targetSdkVersion="19"

代码:

代码语言:javascript
复制
    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 in styles.xml。

有人对此有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2014-12-23 11:43:31

改变这一点:

代码语言:javascript
复制
numberPicker.setMaxValue(1);
numberPicker.setMinValue(100);

在这方面:

代码语言:javascript
复制
numberPicker.setMaxValue(100);
numberPicker.setMinValue(1);

最小值不能高于最大值。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27619576

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档