本文整理汇总了Java中android.app.DatePickerDialog.OnDateSetListener类的典型用法代码示例。如果您正苦于以下问题:Java OnDateSetListener类的具体用法?Java OnDateSetListener怎么用?Java OnDateSetListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnDateSetListener类属于android.app.DatePickerDialog包,在下文中一共展示了OnDateSetListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateDialog
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Find the TaskEditFragment that created this dialog by name.
// We'll use that fragment as the edit callback,
// so that when the user chooses a new date in our datepicker
// dialog, the dialog will call back into the edit fragment to
// set the new date.
OnDateSetListener callback = (OnDateSetListener)
getFragmentManager()
.findFragmentByTag
(TaskEditFragment
.DEFAULT_FRAGMENT_TAG);
// Construct a new DatePicker dialog that will be hosted by
// this fragment. Set its Year, Month, and Day to the values
// specified in the args bundle
Bundle args = getArguments();
return new DatePickerDialog(getActivity(), callback,
args.getInt(YEAR),
args.getInt(MONTH),
args.getInt(DAY));
}
示例2: setBtn_chaxunClickListener
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
private void setBtn_chaxunClickListener(View view) {
DatePickerDialog dpd = new MyPickerDialog(MainActivity.this,
new OnDateSetListener() {
@Override
public void onDateSet(DatePicker arg0, int year, int month,
int day) {
String data = year + "年" + (month + 1) + "月";
tv_curYearMonth.setText(data);
list = aDao.selectByData(data);
setAdapter();
jisuan();
}
}, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH));
dpd.show();
}
示例3: showDatePickerDialog
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
/**
* use to show datepicker
*
* @param mContext
* @param format of the date format
* @param mTextView in which you have to set selected date
*/
public static void showDatePickerDialog(final Context mContext,
final String format, final TextView mTextView) {
new DatePickerDialog(mContext, new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
SimpleDateFormat dateFormatter = new SimpleDateFormat(format);
dateTime.set(year, monthOfYear, dayOfMonth);
mTextView.setText(dateFormatter.format(dateTime.getTime()));
}
}, dateTime.get(Calendar.YEAR), dateTime.get(Calendar.MONTH),
dateTime.get(Calendar.DAY_OF_MONTH)).show();
}
示例4: getEndDate
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
/**
* �������� : getEndDate �������� : ����������ֵ˵����
*
* @param etEndDate2
*
* �ļ�¼�� ���� ��2015��10��30�� ����5:48:49 ���ˣ�hxf ���� ��
*
*/
protected void getEndDate() {
// TODO Auto-generated method stub
new DatePickerDialog(ManagerCountActivity.this, new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
String month = String.valueOf(monthOfYear + 1);
String day = String.valueOf(dayOfMonth);
if (dayOfMonth >= 1 && dayOfMonth <= 9) {
day = "0" + day;
}
if (monthOfYear >= 0 && monthOfYear <= 8) {
month = "0" + month;
}
etEndDate.setText(year + "-" + month + "-" + day);
}
}, year, monthOfYear, dayOfMonth).show();
}
示例5: getBeginDate
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
/**
* �������� : getBeginDate �������� : ����������ֵ˵����
*
* @param etBeginDate2
*
* �ļ�¼�� ���� ��2015��10��30�� ����5:48:49 ���ˣ�hxf ���� ��
*
*/
protected void getBeginDate() {
// TODO Auto-generated method stub
// ʹ��DatePickerDialog�Ի�������ʹ�������ڲ��ʽ����һ�����ڶԻ���
new DatePickerDialog(ManagerCountActivity.this, new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
String month = String.valueOf(monthOfYear + 1);
String day = String.valueOf(dayOfMonth);
if (dayOfMonth >= 1 && dayOfMonth <= 9) {
day = "0" + day;
}
if (monthOfYear >= 0 && monthOfYear <= 8) {
month = "0" + month;
}
etBeginDate.setText(year + "-" + month + "-" + day);
}
}, year, monthOfYear, dayOfMonth).show();// ���������������ڶԻ����ʼ��ʱ���õ�ʱ�䣬���һ��Ҫ����show��������
}
示例6: createDateSetListener
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
private OnDateSetListener createDateSetListener() {
OnDateSetListener listener = new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, final int year, final int monthOfYear, final int dayOfMonth) {
final FragmentActivity act = getActivity();
if(!isDetached() && !isRemoving() && act != null) {
act.runOnUiThread(new Runnable() {
DateFormat df = new SimpleDateFormat("cc, dd.MM.yyyy", Locale.GERMANY);
@Override
public void run() {
controller.setDate(year, monthOfYear, dayOfMonth);
String title = act.getString(R.string.title_activity_attendance) + " " + df.format(controller.getAttendanceDate().getTime());
txtTitle.setText(title);
refreshList();
}
});
}
}
};
return listener ;
}
示例7: onBirthdayClick
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
public void onBirthdayClick(View view) {
if (mDatePickerDialog == null) {
mDatePickerDialog = new DatePickerDialog(RegisterActivity.this,
new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
// TODO Auto-generated method stub
mBirthdayEditText.setText(String.format(
"%04d-%02d-%02d", year, monthOfYear + 1,
dayOfMonth));
mCalendar.set(Calendar.YEAR, year);
mCalendar.set(Calendar.MONTH, monthOfYear);
mCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
}
}, 1980, 0, 1);
mCalendar.set(Calendar.YEAR, 1980);
mCalendar.set(Calendar.MONTH, 0);
mCalendar.set(Calendar.DAY_OF_MONTH, 1);
mDatePickerDialog.setCanceledOnTouchOutside(true);
mDatePickerDialog
.setTitle(getString(R.string.str_hint_select_birthday));
}
mDatePickerDialog.show();
}
示例8: setDateTimeField
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
private void setDateTimeField() {
edt_birthday.setOnFocusChangeListener(this);
Calendar newCalendar = Calendar.getInstance();
BirthdayDatePickerDialog = new DatePickerDialog(this, R.style.DatePickerStyle, new OnDateSetListener() {
// BirthdayDatePickerDialog = new DatePickerDialog(this, new OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Calendar newDate = Calendar.getInstance();
newDate.set(year, monthOfYear, dayOfMonth);
edt_birthday.setText(dateFormatter.format(newDate.getTime()));
}
},newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.WEEK_OF_MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
BirthdayDatePickerDialog.setTitle("");
}
示例9: selectDateFrom
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
public void selectDateFrom() {
DatePickerFragment dialog = new DatePickerFragment();
if(dateFrom != null) {
Bundle args = new Bundle(1);
args.putLong(DatePickerFragment.ARG_INITIAL_DATE, dateFrom.getTime());
dialog.setArguments(args);
}
dialog.setListener(new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
dateFrom = DateUtils.getDate(year, monthOfYear, dayOfMonth).getTime();
refreshButtons();
refreshAnalysis();
}
});
dialog.show(getFragmentManager(), "datePicker");
}
开发者ID:NEUROINFORMATICS-GROUP-FAV-KIV-ZCU,项目名称:elfyz-data-mobile-logger,代码行数:18,代码来源:AAnalysisFragment.java
示例10: selectDateTo
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
public void selectDateTo() {
DatePickerFragment dialog = new DatePickerFragment();
if(dateTo != null) {
Bundle args = new Bundle(1);
args.putLong(DatePickerFragment.ARG_INITIAL_DATE, dateTo.getTime());
dialog.setArguments(args);
}
dialog.setListener(new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
dateTo = DateUtils.getDate(year, monthOfYear, dayOfMonth).getTime();
refreshButtons();
refreshAnalysis();
}
});
dialog.show(getFragmentManager(), "datePicker");
}
开发者ID:NEUROINFORMATICS-GROUP-FAV-KIV-ZCU,项目名称:elfyz-data-mobile-logger,代码行数:18,代码来源:AAnalysisFragment.java
示例11: showDatePickerDialog
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
public void showDatePickerDialog(View v, String tag, final EditText dateEditText, final int[] dateStrings) {
DatePickerFragment datePicker = new DatePickerFragment();
Calendar calender = Calendar.getInstance();
Bundle args = new Bundle();
args.putInt("year", calender.get(Calendar.YEAR));
args.putInt("month", calender.get(Calendar.MONTH));
args.putInt("day", calender.get(Calendar.DAY_OF_MONTH));
datePicker.setArguments(args);
OnDateSetListener ondate = new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int day) {
dateEditText.setText(day + "/" + (month + 1) + "/" + year);
dateStrings[0] = year;
dateStrings[1] = month + 1;
dateStrings[2] = day;
}
};
datePicker.setCallBack(ondate);
datePicker.show(getFragmentManager(), tag);
}
示例12: showDatePickerDialog
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
public void showDatePickerDialog(View v, String tag, final EditText dateEditText, final int[] date) {
DatePickerFragment datePicker = new DatePickerFragment();
Calendar calender = Calendar.getInstance();
Bundle args = new Bundle();
args.putInt("year", calender.get(Calendar.YEAR));
args.putInt("month", calender.get(Calendar.MONTH));
args.putInt("day", calender.get(Calendar.DAY_OF_MONTH));
datePicker.setArguments(args);
OnDateSetListener ondate = new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int day) {
dateEditText.setText(day + "/" + (month + 1) + "/" + year);
date[0] = year;
date[1] = month + 1;
date[2] = day;
}
};
datePicker.setCallBack(ondate);
datePicker.show(getFragmentManager(), tag);
}
示例13: createDialog
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
@Override
protected AlertDialog createDialog(final Calendar cal) {
OnDateSetListener callback = new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, monthOfYear);
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
listener.onValuePicked(String.valueOf(cal.getTimeInMillis()));
}
};
DatePickerDialog dialog = new DatePickerDialog(activity, callback, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
return dialog;
}
示例14: pickDateTime
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
/**
* 日期和时间选择对话框,选选择日期后选择时间
*
* @param con 上下文
* @param title1 日期选择标题
* @param title2 事件选择标题
* @param calendar 默认日期
* @param listener 时间选择事件
*/
public static void pickDateTime(final Context con, String title1, final String title2, final Calendar calendar, final OnTimeSetListener listener) {
// 增加判断,解决4.X系统可能存在的弹出多个时间选择器的问题
final boolean[] isShowTime = {false};
pickDate(con, title1, calendar, new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
calendar.set(year, month, dayOfMonth);
if (!isShowTime[0]) {
isShowTime[0] = true;
pickTime(con, title2, calendar, listener);
}
}
});
}
示例15: pickMonth
import android.app.DatePickerDialog.OnDateSetListener; //导入依赖的package包/类
/**
* 年月选择对话框
*
* @param con
* @param title
* @param calendar
* @param listener
*/
public static void pickMonth(Context con, String title, Calendar calendar, final OnDateSetListener listener) {
LinearLayout ll = new LinearLayout(con);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(layoutParams);
ll.setOrientation(LinearLayout.VERTICAL);
//添加一条线
LinearLayout line = new LinearLayout(con);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1);
line.setBackgroundColor(con.getResources().getColor(R.color.line));
line.setLayoutParams(lp);
ll.addView(line);
//添加选择器控件
final DatePicker datePicker = new DatePicker(con, null, themeId);
datePicker.setLayoutParams(layoutParams);
datePicker.init(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), null);
datePicker.setCalendarViewShown(false);
ll.addView(datePicker);
//初始化对话框
QuickDialog.Builder builder = new QuickDialog.Builder(con);
builder.setContentView(ll);
builder.setTitle(title);
builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
listener.onDateSet(datePicker, datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
}
});
builder.create().show();
}