当前位置: 首页>>代码示例>>Java>>正文


Java DatePickerDialog.show方法代码示例

本文整理汇总了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();
}
 
开发者ID:HowieTianDev,项目名称:ChenYan,代码行数:17,代码来源:PublishAActivity.java

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

}
 
开发者ID:HowieTianDev,项目名称:ChenYan,代码行数:19,代码来源:MyInfoActivity.java

示例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);
}
 
开发者ID:strudelauxpommes,项目名称:FitnessHabits,代码行数:21,代码来源:MainActivity.java

示例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();
}
 
开发者ID:Welloculus,项目名称:MobileAppForPatient,代码行数:21,代码来源:CalendarDialog.java

示例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();
}
 
开发者ID:StringflowServer,项目名称:Beach-Android,代码行数:19,代码来源:PollActivity.java

示例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();
}
 
开发者ID:franmontiel,项目名称:LocaleChanger,代码行数:18,代码来源:SampleActivity.java

示例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();
}
 
开发者ID:darsh2,项目名称:CouponsTracker,代码行数:21,代码来源:CouponFragment.java

示例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();
    }
}
 
开发者ID:dhbw-timetable,项目名称:dhbw-timetable-android,代码行数:20,代码来源:WeekFragment.java

示例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();
}
 
开发者ID:billthefarmer,项目名称:diary,代码行数:11,代码来源:Diary.java

示例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();
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:16,代码来源:DateUI.java

示例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();
}
 
开发者ID:Dentacoin,项目名称:aftercare-app-android,代码行数:40,代码来源:DCUtils.java

示例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();
}
 
开发者ID:strudelauxpommes,项目名称:FitnessHabits,代码行数:10,代码来源:ParameterActivity.java

示例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();
}
 
开发者ID:PocketX,项目名称:PocketKnell,代码行数:13,代码来源:ChooseDateActivity.java

示例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();
}
 
开发者ID:mvescovo,项目名称:item-reaper,代码行数:44,代码来源:EditItemFragment.java

示例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();
}
 
开发者ID:neurospeech,项目名称:ui-atoms-android,代码行数:11,代码来源:DatePickerEditView.java


注:本文中的android.app.DatePickerDialog.show方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。