Java Code Examples for android.widget.DatePicker

The following examples show how to use android.widget.DatePicker. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: Android-Commons   Source File: UI.java    License: Apache License 2.0 6 votes vote down vote up
/**
* Sets whether the year should be visible and selectable in the given `DatePicker` instance
*
* @param picker the `DatePicker` instance
* @param yearVisible whether the year should be visible or not
*/
  public static void setDatePickerYearVisible(final DatePicker picker, final boolean yearVisible) {
  	try {
   	final Field f[] = picker.getClass().getDeclaredFields();

   	for (Field field : f) {
    	if (field.getName().equals("mYearPicker") || field.getName().equals("mYearSpinner")) {
	    	field.setAccessible(true);
	    	Object yearPicker = new Object();
	    	yearPicker = field.get(picker);
	    	((View) yearPicker).setVisibility(yearVisible ? View.VISIBLE : View.GONE);
    	}
   	}
  	}
  	catch (Exception e) { }
  }
 
Example 2
Source Project: SmsScheduler   Source File: BuilderDate.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public DatePicker build() {
    getView().init(
        sms.getCalendar().get(GregorianCalendar.YEAR),
        sms.getCalendar().get(GregorianCalendar.MONTH),
        sms.getCalendar().get(GregorianCalendar.DAY_OF_MONTH),
        new DatePicker.OnDateChangedListener() {
            @Override
            public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                sms.getCalendar().set(GregorianCalendar.YEAR, year);
                sms.getCalendar().set(GregorianCalendar.MONTH, monthOfYear);
                sms.getCalendar().set(GregorianCalendar.DAY_OF_MONTH, dayOfMonth);
            }
        }
    );
    return getView();
}
 
Example 3
Source Project: Mizuu   Source File: EditMovieFragment.java    License: Apache License 2.0 6 votes vote down vote up
private void showDatePickerDialog(String initialValue) {
    String[] dateArray = initialValue.split("-");
    Calendar cal = Calendar.getInstance();
    cal.set(Integer.parseInt(dateArray[0]), Integer.parseInt(dateArray[1]) - 1, Integer.parseInt(dateArray[2]));
    DatePickerDialog dialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            // Update the date
            mMovie.setReleaseDate(year, monthOfYear + 1, dayOfMonth);

            // Update the UI with the new value
            setupValues(false);
        }
    }, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
    dialog.show();
}
 
Example 4
Source Project: msdkui-android   Source File: TravelTimePicker.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity())
            .setNegativeButton(R.string.msdkui_cancel, null)
            .setPositiveButton(R.string.msdkui_ok, null);

    final View view = View.inflate(getActivity(), R.layout.travel_time_picker, null);
    dialogBuilder.setView(view);

    mTabLayout = (TabLayout) view.findViewById(R.id.picker_tab);
    mDatePicker = (DatePicker) view.findViewById(R.id.travel_date);
    mTimePicker = (TimePicker) view.findViewById(R.id.travel_time);
    mTimePicker.setIs24HourView(DateFormat.is24HourFormat(getActivity()));

    updateDefaultValues();
    updateTab(savedInstanceState);
    updateDatePicker(savedInstanceState);
    updateTimePicker(savedInstanceState);
    updateVisibility(savedInstanceState);

    final Dialog dialog = dialogBuilder.create();
    dialog.setOnShowListener(mOnShowListener);
    return dialog;
}
 
Example 5
Source Project: VideoMeeting   Source File: DateTimePickDialogUtil.java    License: Apache License 2.0 6 votes vote down vote up
public void init(DatePicker datePicker, TimePicker timePicker) {
    Calendar calendar = Calendar.getInstance();
    if (!(null == initDateTime || "".equals(initDateTime))) {
        calendar = this.getCalendarByInintData(initDateTime);
    } else {
        initDateTime = calendar.get(Calendar.YEAR) + "年"
                + calendar.get(Calendar.MONTH) + "月"
                + calendar.get(Calendar.DAY_OF_MONTH) + "日 "
                + calendar.get(Calendar.HOUR_OF_DAY) + ":"
                + calendar.get(Calendar.MINUTE);
    }

    datePicker.init(calendar.get(Calendar.YEAR),
            calendar.get(Calendar.MONTH),
            calendar.get(Calendar.DAY_OF_MONTH), this);
    timePicker.setCurrentHour(calendar.get(Calendar.HOUR_OF_DAY));
    timePicker.setCurrentMinute(calendar.get(Calendar.MINUTE));
}
 
Example 6
Source Project: DynamicCalendar   Source File: BasicActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    mCurrentDate = Calendar.getInstance();
    int mYear = mCurrentDate.get(Calendar.YEAR);
    int mMonth = mCurrentDate.get(Calendar.MONTH);
    int mDay = mCurrentDate.get(Calendar.DAY_OF_MONTH);

    DatePickerDialog mDatePicker = new DatePickerDialog(BasicActivity.this, new DatePickerDialog.OnDateSetListener() {
        public void onDateSet(DatePicker datepicker, int selectedYear, int selectedMonth, int selectedDay) {
            // Update the editText to display the selected date
            mDateEditText.setText(selectedDay + "-" + (selectedMonth + 1) + "-" + selectedYear);

            // Set the mCurrentDate to the selected date-month-year
            mCurrentDate.set(selectedYear, selectedMonth, selectedDay);
            mGeneratedDateIcon = mImageGenerator.generateDateImage(mCurrentDate, R.drawable.empty_calendar);
            mDisplayGeneratedImage.setImageBitmap(mGeneratedDateIcon);

        }
    }, mYear, mMonth, mDay);
    mDatePicker.show();
}
 
Example 7
private void showCustomCalendar() {
    DatePickerUtils.getDatePickerDialog(getContext(), label, date, allowFutureDates,
            new DatePickerUtils.OnDatePickerClickListener() {
                @Override
                public void onNegativeClick() {
                    editText.setText(null);
                    listener.onDateSelected(null);
                }

                @Override
                public void onPositiveClick(DatePicker datePicker) {
                    selectedCalendar.set(Calendar.YEAR, datePicker.getYear());
                    selectedCalendar.set(Calendar.MONTH, datePicker.getMonth());
                    selectedCalendar.set(Calendar.DAY_OF_MONTH, datePicker.getDayOfMonth());
                    selectedCalendar.set(Calendar.HOUR_OF_DAY, 0);
                    selectedCalendar.set(Calendar.MINUTE, 0);
                    Date selectedDate = selectedCalendar.getTime();
                    String result = DateUtils.uiDateFormat().format(selectedDate);
                    editText.setText(result);
                    listener.onDateSelected(selectedDate);
                    nextFocus(DateTableView.this);
                }
            }).show();
}
 
Example 8
Source Project: WifiChat   Source File: SettingInfoActivity.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void initViews() {

    mIvAvater = (ImageView) findViewById(R.id.setting_my_avater_img);
    mEtNickname = (EditText) findViewById(R.id.setting_my_nickname);
    mRgGender = (RadioGroup) findViewById(R.id.setting_baseinfo_rg_gender);
    mHtvConstellation = (TextView) findViewById(R.id.setting_birthday_htv_constellation);
    mHtvAge = (TextView) findViewById(R.id.setting_birthday_htv_age);
    mDpBirthday = (DatePicker) findViewById(R.id.setting_birthday_dp_birthday);

    mRbBoy = (RadioButton) findViewById(R.id.setting_baseinfo_rb_male);
    mRbGirl = (RadioButton) findViewById(R.id.setting_baseinfo_rb_female);

    mBtnBack = (Button) findViewById(R.id.setting_btn_back);
    mBtnNext = (Button) findViewById(R.id.setting_btn_next);

}
 
Example 9
private void displayDatePicker() {
    final Calendar myCalendar = Calendar.getInstance();

    DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear,
                              int dayOfMonth) {
            myCalendar.set(Calendar.YEAR, year);
            myCalendar.set(Calendar.MONTH, monthOfYear);
            myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            updateLabel();
        }

        private void updateLabel() {

            DateFormat dateFormat = getDateFormat();

            birthDay.setText(dateFormat.format(myCalendar.getTime()));
        }
    };

    new DatePickerDialog(CreateNewUserActivity.this, date, myCalendar
            .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
            myCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
 
Example 10
Source Project: Expense-Tracker-App   Source File: SelectDateFragment.java    License: MIT License 6 votes vote down vote up
private void showDateDialog(final int id) {
    final Calendar calendar = Calendar.getInstance();
    calendar.setTime(id == R.id.btn_date_from ? DateManager.getInstance().getDateFrom() : DateManager.getInstance().getDateTo());
    DialogManager.getInstance()
            .showDatePicker(
                    getContext(),
                    new DatePickerDialog.OnDateSetListener() {
                        @Override
                        public void onDateSet(DatePicker datePicker, int year, int month, int day) {
                            calendar.set(year, month, day);
                            DateUtils.setDateStartOfDay(calendar);
                            if (id == R.id.btn_date_from) {
                                DateManager.getInstance().setDateFrom(calendar.getTime());
                                updateDate(btnDateFrom, DateManager.getInstance().getDateFrom());
                            } else {
                                DateManager.getInstance().setDateTo(calendar.getTime());
                                updateDate(btnDateTo, DateManager.getInstance().getDateTo());
                            }
                            iSelectDateFragment.updateData();
                        }
                    },
                    calendar,
                    (R.id.btn_date_from == id) ? null : DateManager.getInstance().getDateFrom(),
                    (R.id.btn_date_from == id) ? DateManager.getInstance().getDateTo() : null);
}
 
Example 11
Source Project: Android-POS   Source File: SearchInvoiceTabFrg.java    License: MIT License 6 votes vote down vote up
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {

    int fromDTemp = Integer.parseInt(fromDate);//yearMonthDay
    int toDTemp = Integer.parseInt(String.valueOf(year)+String.valueOf(month)+String.valueOf(dayOfMonth));//yearMonthDay


    if (fromDTemp <= toDTemp){
        toDate = year+month+dayOfMonth+"";
        binding.toDateInBtn.setText(dayOfMonth+"."+month+"."+year);

    }else {
        Toast.makeText(getActivity(),"From date can,t be lower then to date",Toast.LENGTH_SHORT).show();
        binding.toDateInBtn.setText("Select to");
        toDate = "0";
    }

    if (!toDate.equals("0") && !fromDate.equals("0")){
        validDate =true;
    }else validDate = false;

}
 
Example 12
Source Project: SSForms   Source File: FormAdapter.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    mCalendarCurrentDate.set(Calendar.YEAR, year);
    mCalendarCurrentDate.set(Calendar.MONTH, monthOfYear);
    mCalendarCurrentDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);

    String myFormatDate = "dd/MM/yy"; // custom format
    SimpleDateFormat sdfDate = new SimpleDateFormat(myFormatDate, Locale.US);

    // act only if clicked position is a valid index
    if (clickedPosition >= 0) {
        FormElementDateTime fe = (FormElementDateTime) mDataset.get(clickedPosition);
        fe.setValue(mCalendarCurrentTime.getTime());
        DateTimeCallBack dateTimeCallBack = fe.getCallback();
        dateTimeCallBack.callbackDateTimeReturn(mCalendarCurrentDate.getTime(), fe, fe.getTag());
        notifyItemChanged(clickedPosition);
        clickedPosition = -1;

    }
}
 
Example 13
Source Project: SSForms   Source File: FormAdapter.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    mCalendarCurrentDate.set(Calendar.YEAR, year);
    mCalendarCurrentDate.set(Calendar.MONTH, monthOfYear);
    mCalendarCurrentDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);

    String myFormatDate = "dd/MM/yy"; // custom format
    SimpleDateFormat sdfDate = new SimpleDateFormat(myFormatDate, Locale.US);

    // act only if clicked position is a valid index
    if (clickedPosition >= 0) {
        FormElementDateTime fe = (FormElementDateTime) mDataset.get(clickedPosition);
        fe.setValue(mCalendarCurrentTime.getTime());
        DateTimeCallBack dateTimeCallBack = fe.getCallback();
        dateTimeCallBack.callbackDateTimeReturn(mCalendarCurrentDate.getTime(), fe, fe.getTag());
        clickedPosition = -1;

    }
}
 
Example 14
Source Project: RoomBookerMVP   Source File: NewEventActivity.java    License: MIT License 6 votes vote down vote up
private void displayDatePicker(final EditText destination) {
    DatePickerFragment datePickerFragment = new DatePickerFragment();
    datePickerFragment.setOnDateSetListener(new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(year, monthOfYear, dayOfMonth);
            String displayDate = simpleDateFormat.format(calendar.getTime());
            destination.setText(displayDate);
            switch (destination.getId()) {
                case R.id.ane_start_date:
                    newEventPresenter.setStartDate(year, monthOfYear, dayOfMonth);
                    break;
                case R.id.ane_end_date:
                    newEventPresenter.setEndDate(year, monthOfYear, dayOfMonth);
                    break;
            }
        }
    });
    datePickerFragment.show(getSupportFragmentManager(), DatePickerFragment.TAG);
}
 
Example 15
public void showStartDatePickerDialog(View v) {
    DatePickerFragment newFragment = new DatePickerFragment();
    newFragment.setData(new DatePickerDialog.OnDateSetListener (){
                            @Override
                            public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                                start.set(Calendar.YEAR, year);
                                start.set(Calendar.MONTH, month);
                                start.set(Calendar.DAY_OF_MONTH, dayOfMonth);

                                Long newStart = Long.valueOf(start.getTimeInMillis());
                                updateValues.put(ActivityDiaryContract.Diary.START, newStart);
                                updateDateTimes();
                            }
                        }
            , start.get(Calendar.YEAR), start.get(Calendar.MONTH), start.get(Calendar.DAY_OF_MONTH));
    newFragment.show(getSupportFragmentManager(), "startDatePicker");
}
 
Example 16
Source Project: SmsScheduler   Source File: AddSmsActivity.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void buildForm() {
    EditText formMessage = findViewById(R.id.form_input_message);
    AutoCompleteTextView formContact = findViewById(R.id.form_input_contact);
    TextWatcher watcherEmptiness = new EmptinessTextWatcher(this, formContact, formMessage);
    formContact.addTextChangedListener(watcherEmptiness);
    formMessage.addTextChangedListener(watcherEmptiness);

    new BuilderMessage().setView(formMessage).setSms(sms).build();
    new BuilderContact().setView(formContact).setSms(sms).setActivity(this).build();

    new BuilderSimCard().setActivity(this).setView(findViewById(R.id.form_sim_card)).setSms(sms).build();
    new BuilderRecurringMode()
        .setRecurringDayView((Spinner) findViewById(R.id.form_recurring_day))
        .setRecurringMonthView((Spinner) findViewById(R.id.form_recurring_month))
        .setDateView((DatePicker) findViewById(R.id.form_date))
        .setActivity(this)
        .setView(findViewById(R.id.form_recurring_mode))
        .setSms(sms)
        .build()
    ;

    new BuilderTime().setActivity(this).setView(findViewById(R.id.form_time)).setSms(sms).build();
    new BuilderDate().setActivity(this).setView(findViewById(R.id.form_date)).setSms(sms).build();

    new BuilderCancel().setView(findViewById(R.id.button_cancel)).setSms(sms).build();
}
 
Example 17
Source Project: AndroidRipper   Source File: Setter.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Sets the date in a given {@link DatePicker}.
 *
 * @param datePicker the {@code DatePicker} object.
 * @param year the year e.g. 2011
 * @param monthOfYear the month which is starting from zero e.g. 03
 * @param dayOfMonth the day e.g. 10
 */

public void setDatePicker(final DatePicker datePicker, final int year, final int monthOfYear, final int dayOfMonth) {
	if(datePicker != null){
		Activity activity = activityUtils.getCurrentActivity(false);
		if(activity != null){
			activity.runOnUiThread(new Runnable()
			{
				public void run()
				{
					try{
						datePicker.updateDate(year, monthOfYear, dayOfMonth);
					}catch (Exception ignored){}
				}
			});
		}
	}
}
 
Example 18
Source Project: Android-Example   Source File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	dp=(DatePicker)findViewById(R.id.DP1);
	bt=(Button)findViewById(R.id.button1);
	tv1=(TextView)findViewById(R.id.textView1);
	tv2=(TextView)findViewById(R.id.textView2);
	tv3=(TextView)findViewById(R.id.textView3);
	bt.setOnClickListener(new OnClickListener() 
	{
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			i1=dp.getDayOfMonth();
			s1=dp.getMonth();
			i2=dp.getYear();
			tv1.setText(String.valueOf(i1));
			tv2.setText(String.valueOf(s1));
			tv3.setText(String.valueOf(i2));
		}
	});

}
 
Example 19
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    DatePickerDialog dialog = new DatePickerDialog(getActivity(),
            R.style.CustomDatePickerDialogTheme, this, mParent.mYear, mParent.mMonth, 1);

    DatePicker datePicker = dialog.getDatePicker();

    // Limit range.
    Calendar c = mParent.getCalendar();
    datePicker.setMinDate(c.getTimeInMillis());
    c.set(Calendar.YEAR, mParent.mYear + CC_EXP_YEARS_COUNT - 1);
    datePicker.setMaxDate(c.getTimeInMillis());

    // Remove day.
    datePicker.findViewById(getResources().getIdentifier("day", "id", "android"))
            .setVisibility(View.GONE);
    return dialog;
}
 
Example 20
/**
 * 弹出日期选择对话框
 * <p>
 * 参数:
 * title: 标题
 * datetime: 指定日期 yyyy-MM-dd
 * 返回:
 * date: 格式:yyyy-MM-dd
 */
public static void pickDate(final IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    final String title = param.optString("title");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM-dd"));
    }
    wv.post(new Runnable() {
        public void run() {
            DialogUtil.pickDate(webLoader.getPageControl().getActivity(), title, calendar, new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                    calendar.set(Calendar.YEAR, year);
                    calendar.set(Calendar.MONTH, monthOfYear);
                    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                    String chooseDate = DateUtil.convertDate(calendar.getTime(), "yyyy-MM-dd");
                    Map<String, Object> map = new HashMap<>();
                    map.put("date", chooseDate);
                    callback.applySuccess(map);
                }
            });
        }
    });
}
 
Example 21
/**
 * 弹出年月选择对话框
 * <p>
 * 参数:
 * title: 标题
 * datetime: 指定日期 yyyy-MM
 * 返回:
 * month: 格式:yyyy-MM
 */
public static void pickMonth(final IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    String title = param.optString("title");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM"));
    }
    DialogUtil.pickMonth(webLoader.getPageControl().getActivity(), title, calendar, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            calendar.set(Calendar.YEAR, year);
            calendar.set(Calendar.MONTH, monthOfYear);
            calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            String chooseDate = DateUtil.convertDate(calendar.getTime(), "yyyy-MM");
            Map<String, Object> map = new HashMap<>();
            map.put("month", chooseDate);
            callback.applySuccess(map);
        }
    });
}
 
Example 22
Source Project: xDrip   Source File: StartNewSensor.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if(Sensor.isActive() == false) {
        setContentView(R.layout.activity_start_new_sensor);

        button = (Button)findViewById(R.id.startNewSensor);
        dp = (DatePicker)findViewById(R.id.datePicker);
        tp = (TimePicker)findViewById(R.id.timePicker);
        addListenerOnButton();


    } else {
        Intent intent = new Intent(this, StopSensor.class);
        startActivity(intent);
        finish();
    }
}
 
Example 23
Source Project: gsn   Source File: ActivityDateTimePicker.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void onDateSet(DatePicker view, int year, int monthOfYear,
                      int dayOfMonth) {
	Log.v("time", year + "");
	endTime.setDate(dayOfMonth);
	endTime.setYear(year - 1900);
	endTime.setMonth(monthOfYear);
	updateEndLabel();
}
 
Example 24
Source Project: white-label-event-app   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    final Calendar c = Calendar.getInstance(TimeZone.getTimeZone(event.getTimezoneName()));
    c.setTimeInMillis(clock.getCurrentTimeMillis());
    c.set(Calendar.YEAR, year);
    c.set(Calendar.MONTH, monthOfYear);
    c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
    clock.setCurrentTimeMillis(c.getTimeInMillis());

    int hour_of_day = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);
    getSupportFragmentManager().beginTransaction()
        .add(TimePickerDialogFragment.instantiate(hour_of_day, minute), "time-picker")
        .commit();
}
 
Example 25
Source Project: android_coursera_1   Source File: AddToDoActivity.java    License: MIT License 5 votes vote down vote up
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
		int dayOfMonth) {
	setDateString(year, monthOfYear, dayOfMonth);

	dateView.setText(dateString);
}
 
Example 26
Source Project: accountBook   Source File: ExpenseProcesActivity.java    License: Apache License 2.0 5 votes vote down vote up
public void onDateSet(DatePicker view, int year, int monthOfYear,
                      int dayOfMonth) {
    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
    calendar.set(Calendar.MONTH, monthOfYear);
    calendar.set(Calendar.YEAR, year);
    trade_time_btn.setText(pubFun.format(calendar.getTime()));
}
 
Example 27
Source Project: quickmark   Source File: SearchActivity.java    License: MIT License 5 votes vote down vote up
public void onDateSet(DatePicker view, int year, int monthOfYear,
		int dayOfMonth) {
	mYear = year;// Ϊ��ݸ�ֵ
	mMonth = monthOfYear;// Ϊ�·ݸ�ֵ
	mDay = dayOfMonth;// Ϊ�츳ֵ
	updateDisplay();// ��ʾ���õ�����
}
 
Example 28
Source Project: Android   Source File: SignupFragment.java    License: MIT License 5 votes vote down vote up
public void onDateSet(DatePicker view, int year, int month, int day) {
    Date_of_Birth.setText(view.getDayOfMonth() + " / " + (view.getMonth() + 1) + " / " + view.getYear());
    age = view.getDayOfMonth() + " / " + (view.getMonth() + 1) + " / " + view.getYear();
    age_year = view.getYear();
    if (age_year <= 2002) {
        Date_of_Birth.setTextColor(Color.BLACK);
        animation_view_birth_signup.setAnimation(R.raw.success);
        animation_view_birth_signup.playAnimation();
        } else {
        Date_of_Birth.setTextColor(Color.RED);
        animation_view_birth_signup.setProgress(0);
    }

}
 
Example 29
Source Project: Memory-capsule   Source File: EditActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * //实例化一个日期选择dialog
 */
private void initdatecenterdialog(){
    final Calendar calendar=Calendar.getInstance();
    new DatePickerDialog(this,0, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
            int year=i1+1;
            updateTagsGroup(2,i+"年"+year+"月"+i2+"日");
        }
    },calendar.get(Calendar.YEAR)
            ,calendar.get(Calendar.MONTH)
            ,calendar.get(Calendar.DAY_OF_MONTH)).show();
}
 
Example 30
@Override
public void onDateTimeSet(DatePicker dateView, TimePicker timeView,
        int year, int month, int monthDay,
        int hourOfDay, int minute) {
    if (!mDialogAlreadyDismissed) {
        setFieldDateTimeValue(mDialogType, year, month, monthDay,
                hourOfDay, minute, WEEK_DEFAULT,
                mLocal ? HTML_DATE_TIME_LOCAL_FORMAT : HTML_DATE_TIME_FORMAT);
    }
}