0

I am creating Dialog box with an number picker, How should I do to have a definition beside of the number picker? Something looks like number picker

This is what I had for (without the hours word).

This is my code:

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()));
        }
    });
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Shawn.Y
  • 181
  • 3
  • 14
  • I think this can be a `String` separated with spaces and gravity of item is `right`. Or if i am wrong `Hour` is part of `NumberPicker` or not ? – ADM Mar 23 '18 at 06:36
  • i think the "hour" you means is the hour for time picker? In this case i would like the "hour" just as string, that can replace with week, day etc. – Shawn.Y Mar 23 '18 at 07:01
  • please look at [this answer](https://stackoverflow.com/questions/53466905/spanned-text-in-number-picker/53467327#53467327)(you will find very similar question) – Tamir Abutbul Nov 26 '18 at 15:46

0 Answers0