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


Java DatePickerDialog类代码示例

本文整理汇总了Java中android.app.DatePickerDialog的典型用法代码示例。如果您正苦于以下问题:Java DatePickerDialog类的具体用法?Java DatePickerDialog怎么用?Java DatePickerDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DatePickerDialog类属于android.app包,在下文中一共展示了DatePickerDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateDialog

import android.app.DatePickerDialog; //导入依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current date as the default date in the picker
    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);


    // Create a new instance of DatePickerDialog and return it
    DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(),
            (DatePickerDialog.OnDateSetListener) getActivity(), year, month, day);
    c.set(Calendar.HOUR_OF_DAY, 12);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    datePickerDialog.getDatePicker().setMinDate(c.getTimeInMillis());
    return datePickerDialog;
}
 
开发者ID:talCrafts,项目名称:Udhari,代码行数:19,代码来源:DatePickerFragment.java

示例2: onCreate

import android.app.DatePickerDialog; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.frm_manutencao_cliente);

    mOperacao = getIntent().getExtras().getString("Operacao");

    if (mOperacao.matches("I"))
        setTitle(getString(R.string.i_001));

    if (mOperacao.matches("A")) {
        setTitle(getString(R.string.a_002));
    }

    edtNome = (EditText) findViewById(R.id.edtNome);
    edtFone_1 = (EditText) findViewById(R.id.edtFone_1);
    edtFone_2 = (EditText) findViewById(R.id.edtFone_2);
    edtEmail = (EditText) findViewById(R.id.edtEmail);
    edtEndereco = (EditText) findViewById(R.id.edtEndereco);
    edtObservacoes = (EditText) findViewById(R.id.edtObservacoes);

    edtFone_1.addTextChangedListener(Mask.insert("(##) ####-####", edtFone_1));
    edtFone_2.addTextChangedListener(Mask.insert("(##) ####-####", edtFone_2));

    edtDtCadastro = (EditText) findViewById(R.id.edtDtCadastro);
    edtDtCadastro.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            int iAno = Calendar.getInstance().get(Calendar.YEAR);
            int iMes = Calendar.getInstance().get(Calendar.MONTH);
            int iDia = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);

            if (edtDtCadastro.getText().toString().trim().length() != 0) {
                iDia = Integer.valueOf(edtDtCadastro.getText().toString().split("\\/")[0]);
                iMes = Integer.valueOf(edtDtCadastro.getText().toString().split("\\/")[1]) - 1;
                iAno = Integer.valueOf(edtDtCadastro.getText().toString().split("\\/")[2]);
            }

            DatePickerDialog datePickerDialog = new DatePickerDialog(frmManutencaoClientes.this, new DatePickerDialog.OnDateSetListener() {
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                    Calendar newDate = Calendar.getInstance();
                    newDate.set(year, monthOfYear, dayOfMonth);
                    edtDtCadastro.setText(Funcoes.dateFormat.format(newDate.getTime()));
                }
            }, iAno, iMes, iDia);

            datePickerDialog.show();
        }
    });

    leitura();
}
 
开发者ID:marcelohanel,项目名称:Cash,代码行数:54,代码来源:frmManutencaoClientes.java

示例3: onCreateDialog

import android.app.DatePickerDialog; //导入依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    chooseDate = (TextView) getActivity().findViewById(R.id.choose_date);
    chooseDate2 = (TextView) getActivity().findViewById(R.id.choose_date2);

    String date = chooseDate.getText().toString();
    int year = Integer.parseInt(date.split("-")[0]);
    int month = Integer.parseInt(date.split("-")[1]);
    int day = Integer.parseInt(date.split("-")[2]);

    DatePickerDialog dialog = new DatePickerDialog(getContext(), this, year, month - 1, day);
    dialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
    dialog.getDatePicker().setMaxDate(System.currentTimeMillis() + (long) 29 * 24 * 60 * 60 * 1000);
    dialog.setTitle(null);
    return dialog;
}
 
开发者ID:Akari10032,项目名称:12306_Android,代码行数:17,代码来源:DatePickerFragment.java

示例4: onDatePressed

import android.app.DatePickerDialog; //导入依赖的package包/类
@OnClick(R.id.dateButton)
public void onDatePressed() {
    dateFormatter = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH);
    Calendar newCalendar = Calendar.getInstance();
    fromDatePickerDialog = new DatePickerDialog(RegisterActivity.this, new DatePickerDialog.OnDateSetListener() {

        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar c = Calendar.getInstance();
            c.set(Calendar.YEAR, year);
            c.set(Calendar.MONTH, monthOfYear);
            c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            Calendar currentTime = Calendar.getInstance();
            if ((currentTime.getTimeInMillis() - FOURTEEN_YEARS) >= c.getTimeInMillis()) {
                dateButton.setText(dayOfMonth + "-" + (monthOfYear + 1) + "-" + year);
            } else {
                dialogManager.showPositiveDialog(R.string.age_title, R.string.age_message, android.R.string.ok);
            }
        }

    }
            , newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
    fromDatePickerDialog.show();
}
 
开发者ID:Mun0n,项目名称:MADBike,代码行数:24,代码来源:RegisterActivity.java

示例5: 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

示例6: onCreateDialog

import android.app.DatePickerDialog; //导入依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle bundle = this.getArguments();

    if (bundle == null) {
        return new DatePickerDialog(getActivity(), this, 0, 0, 0);
    }

    mIdView = bundle.getInt(DATE_PICKER_DIALOG_ID_VIEW);
    Long timeInMillis = bundle.getLong(DATE_PICKER_DIALOG_TIME_IN_MILLIS);

    cal.setTimeInMillis(timeInMillis);
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH);
    int day = cal.get(Calendar.DAY_OF_MONTH);

    return new DatePickerDialog(getActivity(), this, year, month, day);
}
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:20,代码来源:DatePickerDiaLogFragment.java

示例7: timeLeftStartDateOnClickBehavior

import android.app.DatePickerDialog; //导入依赖的package包/类
@OnClick(R.id.time_left_from_date_content)
void timeLeftStartDateOnClickBehavior() {
    DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            startCalendar.set(Calendar.YEAR, year);
            startCalendar.set(Calendar.MONTH, monthOfYear);
            startCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            DateFormat sdf = android.text.format.DateFormat.getDateFormat(getBaseContext());
            startDateContent.setText(sdf.format(startCalendar.getTime()));
            setDate1 = true;
        }
    };
    new DatePickerDialog(this, date,
            startCalendar.get(Calendar.YEAR),
            startCalendar.get(Calendar.MONTH),
            startCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:19,代码来源:OperateTimeLeftActivityBase.java

示例8: timeLeftDueDateOnClickBehavior

import android.app.DatePickerDialog; //导入依赖的package包/类
@OnClick(R.id.time_left_due_date_content)
void timeLeftDueDateOnClickBehavior() {
    DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            dueCalendar.set(Calendar.YEAR, year);
            dueCalendar.set(Calendar.MONTH, monthOfYear);
            dueCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            DateFormat sdf = android.text.format.DateFormat.getDateFormat(getBaseContext());
            dueDateContent.setText(sdf.format(dueCalendar.getTime()));
            setDate2 = true;
        }
    };
    new DatePickerDialog(this, date,
            dueCalendar.get(Calendar.YEAR),
            dueCalendar.get(Calendar.MONTH),
            dueCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:19,代码来源:OperateTimeLeftActivityBase.java

示例9: taskDueDateOnClickBehavior

import android.app.DatePickerDialog; //导入依赖的package包/类
@OnClick(R.id.task_due_date_content)
void taskDueDateOnClickBehavior() {
    DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            dueCalendar.set(Calendar.YEAR, year);
            dueCalendar.set(Calendar.MONTH, monthOfYear);
            dueCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            DateFormat sdf = android.text.format.DateFormat.getDateFormat(getBaseContext());
            dueDateContent.setText(sdf.format(dueCalendar.getTime()));
            setDate = true;
        }
    };
    new DatePickerDialog(this, date,
            dueCalendar.get(Calendar.YEAR),
            dueCalendar.get(Calendar.MONTH),
            dueCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:19,代码来源:OperateTaskActivityBase.java

示例10: habitCalendarYearMonthOnClickBehavior

import android.app.DatePickerDialog; //导入依赖的package包/类
@OnClick(R.id.habit_calendar_year_month)
void habitCalendarYearMonthOnClickBehavior() {
    DatePickerDialog.OnDateSetListener dateListener = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            selectedCalendar.set(Calendar.YEAR, year);
            selectedCalendar.set(Calendar.MONTH, monthOfYear);
            selectedCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            habitCalendarView.setCurrentDate(selectedCalendar.getTime());
            updateHabitCalendarYearMonth();
            updateHabitDetails(selectedCalendar.getTime());
        }
    };
    new DatePickerDialog(this.getContext(), dateListener,
            selectedCalendar.get(Calendar.YEAR),
            selectedCalendar.get(Calendar.MONTH),
            selectedCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:19,代码来源:HabitCalendarFragment.java

示例11: taskCalendarYearMonthOnClickBehavior

import android.app.DatePickerDialog; //导入依赖的package包/类
@OnClick(R.id.task_calendar_year_month)
void taskCalendarYearMonthOnClickBehavior() {
    DatePickerDialog.OnDateSetListener dateListener = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            selectedCalendar.set(Calendar.YEAR, year);
            selectedCalendar.set(Calendar.MONTH, monthOfYear);
            selectedCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            taskCalendarView.setCurrentDate(selectedCalendar.getTime());
            updateTaskCalendarYearMonth();
            updateTaskDetails(selectedCalendar.getTime());
        }
    };
    new DatePickerDialog(this.getContext(), dateListener,
            selectedCalendar.get(Calendar.YEAR),
            selectedCalendar.get(Calendar.MONTH),
            selectedCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:19,代码来源:TaskCalendarFragment.java

示例12: pickDate

import android.app.DatePickerDialog; //导入依赖的package包/类
/**
 * 弹出日期选择对话框
 * <p>
 * 参数:
 * title: 标题
 * datetime: 指定日期 yyyy-MM-dd
 * 返回:
 * date: 格式:yyyy-MM-dd
 */
public static void pickDate(final IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    final String title = param.optString("title");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM-dd"));
    }
    wv.post(new Runnable() {
        public void run() {
            DialogUtil.pickDate(webLoader.getPageControl().getActivity(), title, calendar, new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                    calendar.set(Calendar.YEAR, year);
                    calendar.set(Calendar.MONTH, monthOfYear);
                    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                    String chooseDate = DateUtil.convertDate(calendar.getTime(), "yyyy-MM-dd");
                    Map<String, Object> map = new HashMap<>();
                    map.put("date", chooseDate);
                    callback.applySuccess(map);
                }
            });
        }
    });
}
 
开发者ID:quickhybrid,项目名称:quickhybrid-android,代码行数:34,代码来源:UIApi.java

示例13: pickMonth

import android.app.DatePickerDialog; //导入依赖的package包/类
/**
 * 弹出年月选择对话框
 * <p>
 * 参数:
 * title: 标题
 * datetime: 指定日期 yyyy-MM
 * 返回:
 * month: 格式:yyyy-MM
 */
public static void pickMonth(final IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    String title = param.optString("title");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM"));
    }
    DialogUtil.pickMonth(webLoader.getPageControl().getActivity(), title, calendar, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            calendar.set(Calendar.YEAR, year);
            calendar.set(Calendar.MONTH, monthOfYear);
            calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            String chooseDate = DateUtil.convertDate(calendar.getTime(), "yyyy-MM");
            Map<String, Object> map = new HashMap<>();
            map.put("month", chooseDate);
            callback.applySuccess(map);
        }
    });
}
 
开发者ID:quickhybrid,项目名称:quickhybrid-android,代码行数:30,代码来源:UIApi.java

示例14: 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

示例15: onShowDatePickerClick

import android.app.DatePickerDialog; //导入依赖的package包/类
@OnClick(R.id.showDatePicker)
void onShowDatePickerClick() {
    Calendar now = Calendar.getInstance();

    DatePickerDialog dialog = new DatePickerDialog(
            getActivity(),
            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,代码来源:SampleFragment.java


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