0

我正在使用数字选择器创建对话框,我应该如何在数字选择器旁边进行定义?看起来像数字选择器

这就是我所拥有的(没有时间的话)。

这是我的代码:

public void goToSelectDuration(){
    final NumberPicker numberPicker = new NumberPicker(getActivity());
    numberPicker.setMinValue(03);
    numberPicker.setMaxValue(23);

    final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setCancelable(false);
    builder.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.setPositiveButton(R.string.Ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            viewModel.setDisposalDuration(numberPicker.getValue());
            binding.fragmentChartermainDurationtime.setText(Integer.toString(numberPicker.getValue()));
        }
    });
4

0 回答 0