本文整理汇总了Java中android.app.DatePickerDialog.show方法的典型用法代码示例。如果您正苦于以下问题:Java DatePickerDialog.show方法的具体用法?Java DatePickerDialog.show怎么用?Java DatePickerDialog.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.DatePickerDialog
的用法示例。
在下文中一共展示了DatePickerDialog.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showDateDialog
import android.app.DatePickerDialog; //导入方法依赖的package包/类
private void showDateDialog(final TextView textView) {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dialog =
new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
Date date = new Date(i-1900,i1,i2);
textView.setText(formatDate(date));
}
}, year, month, day);
dialog.show();
}
示例2: showDateDialog
import android.app.DatePickerDialog; //导入方法依赖的package包/类
private void showDateDialog(final TextView textView) {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dialog =
new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
// birthday = new Date(i,i1,i2);
Date date = new Date(i - 1900, i1, i2);
textView.setText(formatDate(date));
}
}, year, month, day);
dialog.show();
}
示例3: onOptionsItemSelected
import android.app.DatePickerDialog; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.datepicker) {
Calendar currentDate = Calendar.getInstance();
if (currentDate != null) {
DatePickerDialog datePickerDialog = new DatePickerDialog(this, this, currentDate.get(Calendar.YEAR), currentDate.get(Calendar.MONTH), currentDate.get(Calendar.DAY_OF_MONTH));
datePickerDialog.show();
return true;
}
} else if (item.getItemId() == R.id.param) {
startActivity(new Intent(this, ParameterActivity.class));
return true;
} else if (item.getItemId() == R.id.objectif) {
// activité temporaire, pour expérimenter. à enlever seulement à la fin de la journée
Intent intent = new Intent(this, TestActivity.class);
this.startActivity(intent);
return true;
}
return super.onOptionsItemSelected(item);
}
示例4: showDatePicker
import android.app.DatePickerDialog; //导入方法依赖的package包/类
/**
* Method to display the date picker
*/
public void showDatePicker(){
Calendar mCalendar = Calendar.getInstance();
int year = mCalendar.get(Calendar.YEAR);
mCalendar.set(Calendar.ERA,1);
int month = mCalendar.get(Calendar.MONTH);
int day = mCalendar.get(Calendar.DAY_OF_MONTH);
mCurrentDatePicker = new DatePickerDialog(mActivity,mDatePickerHandler, year, month, day);
mCurrentDatePicker.setButton(DatePickerDialog.BUTTON_POSITIVE, mActivity.getString(R.string.ok),new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
DatePicker datePicker = mCurrentDatePicker.getDatePicker();
mDatePickerHandler.onDateSet(datePicker, datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
}
});
mCurrentDatePicker.show();
}
示例5: openDatePicker
import android.app.DatePickerDialog; //导入方法依赖的package包/类
private void openDatePicker() {
final Calendar c = Calendar.getInstance();
final int mYear = c.get(Calendar.YEAR);
final int mMonth = c.get(Calendar.MONTH);
final int mDay = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
btnPollExpiryTime.setText(dayOfMonth + "-" + (monthOfYear + 1) + "-" + year);
openTimePicker();
}
}, mYear, mMonth, mDay);
datePickerDialog.show();
}
示例6: onShowDatePickerClick
import android.app.DatePickerDialog; //导入方法依赖的package包/类
@OnClick(R.id.showDatePicker)
void onShowDatePickerClick() {
Calendar now = Calendar.getInstance();
DatePickerDialog dialog = new DatePickerDialog(
SampleActivity.this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
}
},
now.get(Calendar.YEAR),
now.get(Calendar.MONTH),
now.get(Calendar.DAY_OF_MONTH));
dialog.show();
}
示例7: showDatePickerDialog
import android.app.DatePickerDialog; //导入方法依赖的package包/类
private void showDatePickerDialog(Calendar calendar) {
DebugLog.logMethod();
if (calendar == null) {
DebugLog.logMessage("Null calendar");
return;
}
DebugLog.logMessage("Calendar time: " + calendar.getTime().toString());
datePickerDialog = new DatePickerDialog(
getContext(),
R.style.PickerTheme,
CouponFragment.this,
calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH)
);
datePickerDialog.getDatePicker().setMinDate(calendar.getTimeInMillis());
datePickerDialog.setTitle(getString(R.string.title_date_picker));
datePickerDialog.show();
}
示例8: pickWeek
import android.app.DatePickerDialog; //导入方法依赖的package包/类
private void pickWeek(final View view, final Activity activity) {
if (!TimetableManager.getInstance().isRunning()) {
DatePickerDialog.OnDateSetListener handler = (dpView, year, month, day) -> {
weekToDisplay.set(Calendar.YEAR, year);
weekToDisplay.set(Calendar.MONTH, month);
weekToDisplay.set(Calendar.DAY_OF_MONTH, day);
Log.i("DATE", "Picked date: " + day + "." + month + "." + year);
displayWeek(view, activity, false);
};
DatePickerDialog dpd = new DatePickerDialog(getContext(), handler,
weekToDisplay.get(Calendar.YEAR),
weekToDisplay.get(Calendar.MONTH),
weekToDisplay.get(Calendar.DAY_OF_MONTH));
dpd.show();
} else {
Toast.makeText(activity, "I'm currently busy, sorry!", Toast.LENGTH_SHORT).show();
}
}
示例9: showDatePickerDialog
import android.app.DatePickerDialog; //导入方法依赖的package包/类
private void showDatePickerDialog(Calendar date)
{
DatePickerDialog dialog = new
DatePickerDialog(this, this,
date.get(Calendar.YEAR),
date.get(Calendar.MONTH),
date.get(Calendar.DATE));
// Show the dialog
dialog.show();
}
示例10: showDate
import android.app.DatePickerDialog; //导入方法依赖的package包/类
private void showDate() {
Calendar c = Calendar.getInstance();
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
int mHour = c.get(Calendar.HOUR_OF_DAY);
int mMinute = c.get(Calendar.MINUTE);
DatePickerDialog dialog =
new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
@Override public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
}
}, mYear, mMonth, mDay);
dialog.show();
}
示例11: pickDate
import android.app.DatePickerDialog; //导入方法依赖的package包/类
/**
* Date picker
* @param context
* @param from
* @param to
* @param listener
*/
public static void pickDate(Context context, Date set, Date from, Date to, final IDatePickerListener listener) {
final Calendar calendar = Calendar.getInstance();
if (set != null) {
calendar.setTime(set);
}
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
DatePickerDialog datePickerDialog = new DatePickerDialog(context, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int y, int m, int d) {
if (listener != null) {
calendar.set(Calendar.YEAR, y);
calendar.set(Calendar.MONTH, m);
calendar.set(Calendar.DAY_OF_MONTH, d);
listener.onPickedDate(calendar.getTime());
}
}
}, year, month, day);
if (from != null) {
datePickerDialog.getDatePicker().setMinDate(from.getTime());
}
if (to != null) {
datePickerDialog.getDatePicker().setMaxDate(to.getTime());
}
datePickerDialog.show();
}
示例12: showDatePickerDialog
import android.app.DatePickerDialog; //导入方法依赖的package包/类
public void showDatePickerDialog(View v) {
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog newFragment = new DatePickerDialog(this, this, year, month, day);
newFragment.show();
}
示例13: chooseDate
import android.app.DatePickerDialog; //导入方法依赖的package包/类
@OnClick(R.id.btn_choose_date)
void chooseDate() {
DatePickerDialog dialog = new DatePickerDialog(this, (view1, year, month, dayOfMonth) -> {
Timber.d("onDateSet: year = %d, month = %d, dayOfMonth = %d.",
year, month, dayOfMonth);
getBirthdayManager().set(Birthday.create(year, month + 1, dayOfMonth));
Toast.makeText(ChooseDateActivity.this, R.string.save_over, Toast.LENGTH_SHORT).show();
startActivity(new Intent(ChooseDateActivity.this, KnellActivity.class));
finish();
}, 1995, 7, 19);
dialog.show();
}
示例14: expiryDateCustomSelected
import android.app.DatePickerDialog; //导入方法依赖的package包/类
private void expiryDateCustomSelected() {
final Calendar today = Calendar.getInstance();
final Calendar yesterday = Calendar.getInstance();
yesterday.add(Calendar.DAY_OF_YEAR, -1);
final Calendar calendar = Calendar.getInstance();
int currentDay = calendar.get(Calendar.DAY_OF_MONTH);
int currentMonth = calendar.get(Calendar.MONTH);
int currentYear = calendar.get(Calendar.YEAR);
DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(),
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
clearExpiryDateString();
calendar.set(Calendar.DAY_OF_MONTH, datePicker.getDayOfMonth());
calendar.set(Calendar.MONTH, datePicker.getMonth());
calendar.set(Calendar.YEAR, datePicker.getYear());
mExpiryDate = calendar;
if (calendar.compareTo(today) == 0) {
mExpiryDateSpinner.setSelection(
mExpiryDateAdapter.getPosition(
getString(R.string.edit_date_today)));
} else if (calendar.compareTo(yesterday) == 0) {
mExpiryDateSpinner.setSelection(
mExpiryDateAdapter.getPosition(
getString(R.string.edit_date_yesterday)));
} else {
mExpiryDateString = getSimpleDateFormat().format(calendar.getTime());
mExpiryDateAdapter.insert(mExpiryDateString, 0);
mExpiryDateSpinner.setSelection(0);
}
if (mExpiryDateListener) {
mPresenter.itemChanged();
}
}
}, currentYear, currentMonth, currentDay);
datePickerDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
mExpiryDateSpinner.setSelection(mPreviousExpiryDateOption);
}
});
datePickerDialog.show();
}
示例15: showDatePicker
import android.app.DatePickerDialog; //导入方法依赖的package包/类
private void showDatePicker() {
DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(),(view, year, month, dayOfMonth) -> {
setSelectedDate(new DateTime(year,month,dayOfMonth,0,0,0));
if(onDateSelectedListener != null) {
onDateSelectedListener.onDateSelected(selectedDate);
}
},selectedDate.getYear(),selectedDate.getMonthOfYear(),selectedDate.getDayOfMonth());
datePickerDialog.show();
}