微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.widget.DatePicker.OnDateChangedListener的实例源码

项目:365browser    文件DateDialognormalizer.java   
/**
 * Sets the current,min,and max values on the given DatePicker and ensures that
 * min <= current <= max,adjusting current and max if needed.
 *
 * @param year The current year to set.
 * @param month The current month to set. 0-based.
 * @param day The current day to set.
 * @param minMillisUtc The minimum allowed date,in milliseconds from the epoch according to a
 *                     proleptic Gregorian calendar (no Julian switch).
 * @param maxMillisUtc The maximum allowed date,in milliseconds from the epoch according to a
 *                     proleptic Gregorian calendar (no Julian switch).
 */
public static void normalize(DatePicker picker,final OnDateChangedListener listener,int year,int month,int day,long minMillisUtc,long maxMillisUtc) {
    DateAndMillis currentDate = DateAndMillis.create(year,month,day);
    DateAndMillis minDate = DateAndMillis.create(minMillisUtc);
    DateAndMillis maxDate = DateAndMillis.create(maxMillisUtc);

    // Ensure min <= current <= max,adjusting current and max if needed.
    if (maxDate.millisForPicker < minDate.millisForPicker) {
        maxDate = minDate;
    }
    if (currentDate.millisForPicker < minDate.millisForPicker) {
        currentDate = minDate;
    } else if (currentDate.millisForPicker > maxDate.millisForPicker) {
        currentDate = maxDate;
    }

    setLimits(picker,currentDate.millisForPicker,minDate.millisForPicker,maxDate.millisForPicker);
    picker.init(currentDate.year,currentDate.month,currentDate.day,listener);
}
项目:AndroidSurvey    文件DateFragment.java   
@Override
protected void createResponseComponent(ViewGroup responseComponent) {
    datePicker = new DatePicker(getActivity());
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.MATCH_PARENT);
    params.gravity = Gravity.CENTER;
    datePicker.setLayoutParams(params);
    Calendar c = Calendar.getInstance();
    datePicker.init(c.get(Calendar.YEAR),c.get(Calendar.MONTH),c.get(Calendar.DAY_OF_MONTH),new OnDateChangedListener() {
                @Override
                public void onDateChanged(DatePicker view,int newYear,int newMonth,int newDay) {
                    getResponse().setResponse((newMonth + 1) + "-" + newDay + "-" + newYear);
                }
            });
    responseComponent.addView(datePicker);
    updateDate(getResponse().getText());
}
项目:AndroidSurvey    文件DateQuestionFragment.java   
protected DatePicker beforeAddViewHook(ViewGroup component) {
    DatePicker datePicker = new DatePicker(getActivity());
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.MATCH_PARENT);
    params.gravity = Gravity.CENTER;
    datePicker.setLayoutParams(params);
    datePicker.setCalendarViewShown(false);
    Calendar c = Calendar.getInstance();
    datePicker.init(c.get(Calendar.YEAR),int newDay) {
                    mDay = newDay;
                    mMonth = newMonth;
                    mYear = newYear;
                    setResponseText();
                }
            });
    component.addView(datePicker);
    return datePicker;
}
项目:android-chromium-view    文件DateDialognormalizer.java   
/**
 * normalizes an existing DateDialogPicker changing the default date if
 * needed to comply with the {@code min} and {@code max} attributes.
 */
static void normalize(DatePicker picker,OnDateChangedListener listener,int hour,int minute,long min,long max) {
    Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    calendar.clear();
    calendar.set(year,day,hour,minute,0);
    if (calendar.getTimeInMillis() < min) {
        calendar.clear();
        calendar.setTimeInMillis(min);
    } else if (calendar.getTimeInMillis() > max) {
        calendar.clear();
        calendar.setTimeInMillis(max);
    }
    picker.init(
            calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH),listener);

    setLimits(picker,max);
}
项目:android-chromium    文件DateDialognormalizer.java   
/**
 * normalizes an existing DateDialogPicker changing the default date if
 * needed to comply with the {@code min} and {@code max} attributes.
 */
static void normalize(DatePicker picker,max);
}
项目:chromium_webview    文件DateDialognormalizer.java   
/**
 * normalizes an existing DateDialogPicker changing the default date if
 * needed to comply with the {@code min} and {@code max} attributes.
 */
static void normalize(DatePicker picker,long minMillis,long maxMillis) {
    Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    calendar.clear();
    calendar.set(year,0);
    if (calendar.getTimeInMillis() < minMillis) {
        calendar.clear();
        calendar.setTimeInMillis(minMillis);
    } else if (calendar.getTimeInMillis() > maxMillis) {
        calendar.clear();
        calendar.setTimeInMillis(maxMillis);
    }
    picker.init(
            calendar.get(Calendar.YEAR),minMillis,maxMillis);
}
项目:cordova-android-chromium    文件DateDialognormalizer.java   
/**
 * normalizes an existing DateDialogPicker changing the default date if
 * needed to comply with the {@code min} and {@code max} attributes.
 */
static void normalize(DatePicker picker,max);
}
项目:matchmylife    文件ProfileEditFragment.java   
private void initView(View view) {
    final OnDateChangedListener dateChangedListener = this;
    dateButton = (Button) view.findViewById(R.id.buttonDate);
    dateButton.setonClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            DatePickerFragment datePickerFragment = new DatePickerFragment();
            datePickerFragment.setProfileAndOnDateChangedListener(profile,dateChangedListener);
            datePickerFragment.show(getActivity().getSupportFragmentManager(),"datePicker");
        }
    });
    updateButtonText();

    nameView = (EditText) view.findViewById(R.id.editTextName);
    if (profile.getName() != null) {
        nameView.setText(profile.getName());
    }
}
项目:DouDouTodoList    文件EditItemView.java   
private void onDateButtonClicked()
{
    mDateLayout = (LinearLayout)mLayoutInflater.inflate(R.layout.date_dialog,null);
    mDatePicker = (DatePicker)mDateLayout.findViewById(R.id.date_picker);
    final Calendar calendar = Calendar.getInstance();
    mDatePicker.init(calendar.get(Calendar.YEAR),new OnDateChangedListener() {

        @Override
        public void onDateChanged(DatePicker view,int monthOfYear,int dayOfMonth) {
            // Todo Auto-generated method stub
            mTodoItemInfo.setDate_year(year);
            mTodoItemInfo.setDate_month(monthOfYear);
            mTodoItemInfo.setDate_day(dayOfMonth);
            mDateString = mTodoItemInfo.getDateString();
        }
    });
    new AlertDialog.Builder(mContext)
    .setTitle(getResources().getString(R.string.date_dialog_title))
    .setView(mDateLayout)
    .setPositiveButton(getResources().getString(R.string.date_dialog_save_button_default_text),new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog,int which) {
            // Todo Auto-generated method stub
            if(mDateString == null){
                mDateString = String.format("%04d-%02d-%02d",calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH) + 1,calendar.get(Calendar.DAY_OF_MONTH));
            }
            mDateButton.setText(mDateString);
        }
    })
    .setNegativeButton(getResources().getString(R.string.date_dialog_cancel_button_default_text),null)
    .show();
}
项目:androidBits    文件DbDateTime.java   
/**
 * Convenience function to set the picker date.
 * @param aCal - Date to set,if null,use getNow().
 * @param aDatePicker - Widget to set.
 * @param aListener - part of the Widget's params
 * @return Returns the Calendar object used.
 */
static public Calendar setDatetoDatePicker(Calendar aCal,DatePicker aDatePicker,OnDateChangedListener aListener) {
    if (aCal==null)
        aCal = getNow();
    if (aDatePicker!=null)
        aDatePicker.init(aCal.get(Calendar.YEAR),aCal.get(Calendar.MONTH),aCal.get(Calendar.DAY_OF_MONTH),aListener);
    return aCal;
}
项目:SlideDateTimePicker    文件DateFragment.java   
/**
 * Create and return the user interface view for this fragment.
 */
@Override
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState)
{
    int theme = getArguments().getInt("theme");
    int initialYear = getArguments().getInt("year");
    int initialMonth = getArguments().getInt("month");
    int initialDay = getArguments().getInt("day");
    Date minDate = (Date) getArguments().getSerializable("minDate");
    Date maxDate = (Date) getArguments().getSerializable("maxDate");

    // Unless we inflate using a cloned inflater with a Holo theme,// on Lollipop devices the DatePicker will be the new-style
    // DatePicker,which is not what we want. So we will
    // clone the inflater that we're given but with our specified
    // theme,then inflate the layout with this new inflater.

    Context contextThemeWrapper = new ContextThemeWrapper(
            getActivity(),theme == SlideDateTimePicker.HOLO_DARK ?
                     android.R.style.Theme_Holo :
                     android.R.style.Theme_Holo_Light);

    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);

    View v = localInflater.inflate(R.layout.fragment_date,container,false);

    mDatePicker = (CustomDatePicker) v.findViewById(R.id.datePicker);
    // block keyboard popping up on touch
    mDatePicker.setDescendantFocusability(DatePicker.FOCUS_BLOCK_DESCENDANTS);
    mDatePicker.init(
        initialYear,initialMonth,initialDay,new OnDateChangedListener() {

            @Override
            public void onDateChanged(DatePicker view,int dayOfMonth)
            {
                mCallback.onDateChanged(year,monthOfYear,dayOfMonth);
            }
        });

    if (minDate != null)
        mDatePicker.setMinDate(minDate.getTime());

    if (maxDate != null)
        mDatePicker.setMaxDate(maxDate.getTime());

    return v;
}
项目:SlideDateTimePicker-master    文件DateFragment.java   
/**
 * Create and return the user interface view for this fragment.
 */
@Override
public View onCreateView(LayoutInflater inflater,dayOfMonth);
            }
        });

    if (minDate != null)
        mDatePicker.setMinDate(minDate.getTime());

    if (maxDate != null)
        mDatePicker.setMaxDate(maxDate.getTime());

    return v;
}
项目:matchmylife    文件DatePickerFragment.java   
public void setProfileAndOnDateChangedListener(Profile profile,OnDateChangedListener listener) {
    this.profile = profile;
    this.listener = listener;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。