private void loadUserDOB() {
    DatePicker.OnDateChangedListener onDateChanged =
        new DatePicker.OnDateChangedListener() {
          @Override
          public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Log.v(
                Globals.TAG,
                "year : "
                    + year
                    + ", monthOfYear : "
                    + monthOfYear
                    + ", dayOfMonth : "
                    + dayOfMonth);
          }
        };

    if (null != user.getDateOfBirth()) {
      String dob[] = user.getDateOfBirth().split("-");
      year = Integer.parseInt(dob[0]);
      month = Integer.parseInt(dob[1]);
      day = Integer.parseInt(dob[2]);

    } else {
      Calendar c = Calendar.getInstance();
      year = c.get(Calendar.YEAR);
      month = c.get(Calendar.MONTH);
      day = c.get(Calendar.DAY_OF_MONTH);
    }

    pickerDOB.init(year, month, day, onDateChanged);
    pickerDOB.setCalendarViewShown(false);
    pickerDOB.setSpinnersShown(true);
  }
Пример #2
0
  @NonNull
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {

    Locale.setDefault(new Locale("ru"));

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    final android.widget.DatePicker datePicker = new android.widget.DatePicker(getActivity());
    datePicker.setCalendarViewShown(false);
    builder.setView(datePicker);

    builder.setTitle(getResources().getString(R.string.choose_date));

    builder.setPositiveButton(
        getResources().getString(R.string.ready),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            editText.setText(
                datePicker.getDayOfMonth()
                    + "-"
                    + (datePicker.getMonth() + 1)
                    + "-"
                    + datePicker.getYear());
          }
        });

    return builder.create();
  }
Пример #3
0
 private void setEndTime(final TimeObject startTime) {
   LinearLayout layout = new LinearLayout(PlayBackActivity.this);
   layout.setOrientation(LinearLayout.VERTICAL);
   layout.setBackgroundColor(getResources().getColor(R.color.white));
   final TimePicker mTimePicker = new TimePicker(PlayBackActivity.this);
   final DatePicker mDatePicker = new DatePicker(PlayBackActivity.this);
   mTimePicker.setDescendantFocusability(TimePicker.FOCUS_BLOCK_DESCENDANTS);
   mTimePicker.setIs24HourView(true);
   mDatePicker.setDescendantFocusability(DatePicker.FOCUS_BLOCK_DESCENDANTS);
   final TextView tv = new TextView(PlayBackActivity.this);
   String time = String.format("%02d:%02d", startTime.getHour(), startTime.getMinute());
   String date =
       String.valueOf(startTime.getYear())
           + "年"
           + String.format("%02d", startTime.getMonth())
           + "月"
           + String.format("%02d", startTime.getDay())
           + "日";
   tv.setText("开始时间:" + date + "  " + time);
   int version = Integer.valueOf(android.os.Build.VERSION.SDK);
   if (version >= 11) mDatePicker.setCalendarViewShown(false);
   layout.addView(tv, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
   layout.addView(
       mDatePicker, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
   layout.addView(
       mTimePicker, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
   new AlertDialog.Builder(PlayBackActivity.this)
       .setTitle("请选择结束时间:")
       .setView(layout)
       .setPositiveButton(
           android.R.string.ok,
           new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface arg0, int arg1) {
               TimeObject endTime =
                   new TimeObject(
                       mTimePicker.getCurrentMinute(),
                       mTimePicker.getCurrentHour(),
                       mDatePicker.getDayOfMonth(),
                       mDatePicker.getMonth() + 1,
                       mDatePicker.getYear());
               System.out.println("时间:" + endTime.getMinute() + "  " + startTime.getMinute());
               onTimeSearch(startTime, endTime);
             }
           })
       .setNegativeButton(
           android.R.string.cancel,
           new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface arg0, int arg1) {}
           })
       .create()
       .show();
 }
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private void initialisePaging(View view) {
    datePickers = new Vector<>();
    FrameLayout fl1 = new FrameLayout(getActivity());
    FrameLayout fl2 = new FrameLayout(getActivity());
    startDatePicker = new DatePicker(getActivity());
    startDatePicker.setLayoutParams(
        new FrameLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER));
    endDatePicker = new DatePicker(getActivity());
    endDatePicker.setLayoutParams(
        new FrameLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER));

    // not entirely necessary since this feature will never be supported
    // below Honeycomb
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      startDatePicker.setCalendarViewShown(false);
      endDatePicker.setCalendarViewShown(false);
    }
    fl1.addView(startDatePicker);
    fl1.setTag("Start Date");
    fl2.addView(endDatePicker);
    fl2.setTag("End Date");

    datePickers.add(fl1);
    datePickers.add(fl2);

    ViewPagerAdapter adapter = new ViewPagerAdapter(datePickers);

    WrappedViewPager pager = (WrappedViewPager) view.findViewById(R.id.wrappedviewpager);
    pager.setPageMargin(2);
    pager.setAdapter(adapter);

    TabPageIndicator tabIndicator = (TabPageIndicator) view.findViewById(R.id.titles);
    tabIndicator.setViewPager(pager);
  }
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private void initialisePaging(View view) {
    datePickers = new Vector<View>();
    FrameLayout fl1 = new FrameLayout(getSherlockActivity());
    FrameLayout fl2 = new FrameLayout(getSherlockActivity());
    startDatePicker = new DatePicker(getSherlockActivity());
    startDatePicker.setLayoutParams(
        new FrameLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER));
    endDatePicker = new DatePicker(getSherlockActivity());
    endDatePicker.setLayoutParams(
        new FrameLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER));

    // this is always true for now, but not so when I get 2.x implemented
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      startDatePicker.setCalendarViewShown(false);
      endDatePicker.setCalendarViewShown(false);
    }
    fl1.addView(startDatePicker);
    fl1.setTag("Start Date");
    fl2.addView(endDatePicker);
    fl2.setTag("End Date");

    datePickers.add(fl1);
    datePickers.add(fl2);

    ViewPagerAdapter adapter = new ViewPagerAdapter(datePickers);

    WrappedViewPager pager = (WrappedViewPager) view.findViewById(R.id.wrappedviewpager);
    pager.setPageMargin(2);
    pager.setAdapter(adapter);

    TabPageIndicator tabIndicator = (TabPageIndicator) view.findViewById(R.id.titles);
    tabIndicator.setViewPager(pager);
  }
Пример #6
0
  public Dialog onCreateDialog(Bundle savedInstanceState) {

    final Calendar calendar = Calendar.getInstance();
    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DAY_OF_MONTH);

    AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
    dialog.setTitle("Elegir Fecha");
    view = getActivity().getLayoutInflater().inflate(R.layout.modelo_datepicker, null);
    datePicker = (DatePicker) view.findViewById(R.id.datepickerFecha);
    datePicker.init(year, month, day, null);
    datePicker.setCalendarViewShown(false);
    btnAceptar = (Button) view.findViewById(R.id.btnAceptarDatePicker);
    btnAceptar.setOnClickListener(this);
    btnCancelar = (Button) view.findViewById(R.id.btnCancelarDatePicker);
    btnCancelar.setOnClickListener(this);
    dialog.setView(view);

    return dialog.create();
  }
Пример #7
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private void makeDateOnlyPickerH() {

    // 月日選択ダイアログを作る
    AlertDialog.Builder builder = new AlertDialog.Builder(getSherlockActivity());
    datePicker = new DatePicker(getSherlockActivity());

    datePicker.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 1);
    int day_id = Resources.getSystem().getIdentifier("day", "id", "android");

    datePicker.findViewById(day_id).setVisibility(View.GONE);
    datePicker.setCalendarViewShown(false);

    dateDialog =
        builder
            .setView(datePicker)
            .setTitle(
                getSherlockActivity().getApplicationContext().getString(R.string.select_month))
            .setPositiveButton(
                android.R.string.ok,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface d, int w) {
                    int month_id = Resources.getSystem().getIdentifier("month", "id", "android");
                    NumberPicker monthView = (NumberPicker) datePicker.findViewById(month_id);
                    int year_id = Resources.getSystem().getIdentifier("year", "id", "android");
                    NumberPicker yearView = (NumberPicker) datePicker.findViewById(year_id);
                    this_month.setText(String.valueOf(monthView.getValue() + 1) + "月");
                    calendar.set(yearView.getValue(), monthView.getValue(), 1, 0, 0, 0);
                    target_year = calendar.get(Calendar.YEAR);
                    target_month = calendar.get(Calendar.MONTH);
                    showCommentList(target_year, target_month, 0, near);
                  }
                })
            .setNegativeButton(android.R.string.cancel, null)
            .create();
  }
Пример #8
0
 private void setupScreen() {
   mPickerDate.setCalendarViewShown(mCalendarViewShown);
   mPickerDate.setSpinnersShown(mSpinnerShown);
 }
Пример #9
0
 public void setCalendarView(boolean value) {
   if (Build.VERSION.SDK_INT >= 11) {
     DatePicker picker = (DatePicker) getNativeView();
     picker.setCalendarViewShown(value);
   }
 }