當前位置: 首頁>>代碼示例>>Java>>正文


Java OnDateSetListener類代碼示例

本文整理匯總了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));
}
 
開發者ID:emmby,項目名稱:easy-a,代碼行數:24,代碼來源:DatePickerDialogFragment.java

示例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();

}
 
開發者ID:BarryLiu,項目名稱:AndroidDemos,代碼行數:20,代碼來源:MainActivity.java

示例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();
}
 
開發者ID:multidots,項目名稱:android-app-common-tasks,代碼行數:23,代碼來源:Common.java

示例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();
}
 
開發者ID:snsdTJ,項目名稱:order_dish,代碼行數:29,代碼來源:ManagerCountActivity.java

示例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��������
}
 
開發者ID:snsdTJ,項目名稱:order_dish,代碼行數:31,代碼來源:ManagerCountActivity.java

示例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 ;
}
 
開發者ID:markuskreth,項目名稱:ClubHelperAndroid,代碼行數:27,代碼來源:PersonListFragment.java

示例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();
}
 
開發者ID:ikantech,項目名稱:yiim_v2,代碼行數:26,代碼來源:RegisterActivity.java

示例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("");

}
 
開發者ID:ComputerEngineering,項目名稱:iWish,代碼行數:19,代碼來源:RegisterActivity.java

示例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);
}
 
開發者ID:jferluna,項目名稱:Android-Project-Manager,代碼行數:23,代碼來源:EditProject.java

示例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);
}
 
開發者ID:jferluna,項目名稱:Android-Project-Manager,代碼行數:23,代碼來源:NewProject.java

示例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;
}
 
開發者ID:snuk182,項目名稱:aceim,代碼行數:17,代碼來源:DatePickerListener.java

示例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);
            }
        }
    });
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:24,代碼來源:DialogUtil.java

示例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();
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:39,代碼來源:DialogUtil.java


注:本文中的android.app.DatePickerDialog.OnDateSetListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。