Search in sources :

Example 1 with DatePickerDialog

use of android.app.DatePickerDialog in project KJFrameForAndroid by kymjs.

the class ViewInject method getDateDialog.

/**
     * 用于创建PopupWindow封装一些公用属性
     */
// private PopupWindow createWindow(View view, int w, int h, int argb) {
// PopupWindow popupView = new PopupWindow(view, w, h);
// popupView.setFocusable(true);
// popupView.setBackgroundDrawable(new ColorDrawable(argb));
// popupView.setOutsideTouchable(true);
// return popupView;
// }
/**
     * 返回一个日期对话框
     */
public void getDateDialog(String title, final TextView textView) {
    final String[] time = SystemTool.getDataTime("yyyy-MM-dd").split("-");
    final int year = StringUtils.toInt(time[0], 0);
    final int month = StringUtils.toInt(time[1], 1);
    final int day = StringUtils.toInt(time[2], 0);
    DatePickerDialog dialog = new DatePickerDialog(textView.getContext(), new OnDateSetListener() {

        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            textView.setText(year + "-" + (monthOfYear + 1) + "-" + dayOfMonth);
        }
    }, year, month - 1, day);
    dialog.setTitle(title);
    dialog.show();
}
Also used : OnDateSetListener(android.app.DatePickerDialog.OnDateSetListener) DatePickerDialog(android.app.DatePickerDialog) DatePicker(android.widget.DatePicker)

Example 2 with DatePickerDialog

use of android.app.DatePickerDialog in project android by owncloud.

the class ExpirationDatePickerDialogFragment method onCreateDialog.

/**
     * {@inheritDoc}
     *
     * @return      A new dialog to let the user choose an expiration date that will be bound to a share link.
     */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Load arguments
    mFile = getArguments().getParcelable(ARG_FILE);
    // Chosen date received as an argument must be later than tomorrow ; default to tomorrow in other case
    final Calendar chosenDate = Calendar.getInstance();
    long tomorrowInMillis = chosenDate.getTimeInMillis() + DateUtils.DAY_IN_MILLIS;
    long chosenDateInMillis = getArguments().getLong(ARG_CHOSEN_DATE_IN_MILLIS);
    if (chosenDateInMillis > tomorrowInMillis) {
        chosenDate.setTimeInMillis(chosenDateInMillis);
    } else {
        chosenDate.setTimeInMillis(tomorrowInMillis);
    }
    // Create a new instance of DatePickerDialog
    DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, chosenDate.get(Calendar.YEAR), chosenDate.get(Calendar.MONTH), chosenDate.get(Calendar.DAY_OF_MONTH));
    // Prevent days in the past may be chosen
    DatePicker picker = dialog.getDatePicker();
    picker.setMinDate(tomorrowInMillis - 1000);
    // Enforce spinners view; ignored by MD-based theme in Android >=5, but calendar is REALLY buggy
    // in Android < 5, so let's be sure it never appears (in tablets both spinners and calendar are
    // shown by default)
    picker.setCalendarViewShown(false);
    return dialog;
}
Also used : DatePickerDialog(android.app.DatePickerDialog) Calendar(java.util.Calendar) DatePicker(android.widget.DatePicker)

Example 3 with DatePickerDialog

use of android.app.DatePickerDialog in project chromeview by pwnall.

the class InputDialogContainer method showDialog.

void showDialog(final int dialogType, int year, int month, int monthDay, int hour, int minute, int second) {
    if (isDialogShowing())
        mDialog.dismiss();
    Time time = normalizeTime(year, month, monthDay, hour, minute, second);
    if (dialogType == sTextInputTypeDate) {
        mDialog = new DatePickerDialog(mContext, new DateListener(dialogType), time.year, time.month, time.monthDay);
        mDialog.setTitle(mContext.getText(R.string.date_picker_dialog_title));
    } else if (dialogType == sTextInputTypeTime) {
        mDialog = new TimePickerDialog(mContext, new TimeListener(dialogType), time.hour, time.minute, DateFormat.is24HourFormat(mContext));
    } else if (dialogType == sTextInputTypeDateTime || dialogType == sTextInputTypeDateTimeLocal) {
        mDialog = new DateTimePickerDialog(mContext, new DateTimeListener(dialogType), time.year, time.month, time.monthDay, time.hour, time.minute, DateFormat.is24HourFormat(mContext));
    } else if (dialogType == sTextInputTypeMonth) {
        mDialog = new MonthPickerDialog(mContext, new MonthListener(dialogType), time.year, time.month);
    }
    mDialog.setButton(DialogInterface.BUTTON_POSITIVE, mContext.getText(R.string.date_picker_dialog_set), (DialogInterface.OnClickListener) mDialog);
    mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, mContext.getText(android.R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            mDialogAlreadyDismissed = true;
            mInputActionDelegate.cancelDateTimeDialog();
        }
    });
    mDialog.setButton(DialogInterface.BUTTON_NEUTRAL, mContext.getText(R.string.date_picker_dialog_clear), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            mDialogAlreadyDismissed = true;
            mInputActionDelegate.replaceDateTime(dialogType, 0, 0, 0, 0, 0, 0);
        }
    });
    mDialogAlreadyDismissed = false;
    mDialog.show();
}
Also used : DatePickerDialog(android.app.DatePickerDialog) DialogInterface(android.content.DialogInterface) Time(android.text.format.Time) TimePickerDialog(android.app.TimePickerDialog)

Example 4 with DatePickerDialog

use of android.app.DatePickerDialog in project robolectric by robolectric.

the class ShadowDatePickerDialogTest method returnsTheInitialYearMonthAndDayPassedIntoTheDatePickerDialog.

@Test
public void returnsTheInitialYearMonthAndDayPassedIntoTheDatePickerDialog() throws Exception {
    Locale.setDefault(Locale.US);
    DatePickerDialog datePickerDialog = new DatePickerDialog(RuntimeEnvironment.application, null, 2012, 6, 7);
    assertThat(shadowOf(datePickerDialog).getYear()).isEqualTo(2012);
    assertThat(shadowOf(datePickerDialog).getMonthOfYear()).isEqualTo(6);
    assertThat(shadowOf(datePickerDialog).getDayOfMonth()).isEqualTo(7);
}
Also used : DatePickerDialog(android.app.DatePickerDialog) Test(org.junit.Test)

Example 5 with DatePickerDialog

use of android.app.DatePickerDialog in project AdMoney by ErnestoGonAr.

the class Detalles_Ingresos_Egresos_Activity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    //noinspection SimplifiableIfStatement
    if (id == R.id.action_borrar) {
        if (this.item2.tipo == 0) {
            new AlertDialog.Builder(this).setMessage("Eliminar Registro?").setCancelable(false).setPositiveButton("Si", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    bd.eliminarEgresos(item2.id);
                    onBackPressed();
                }
            }).setNegativeButton("No", null).show();
        } else {
            //egreso
            new AlertDialog.Builder(this).setMessage("Eliminar Registro?").setCancelable(false).setPositiveButton("Si", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    bd.eliminarIngresos(item2.id);
                    onBackPressed();
                }
            }).setNegativeButton("No", null).show();
        }
    }
    if (id == R.id.action_modificar) {
        categoria.setClickable(true);
        cantidad.setEnabled(true);
        fecha.getEditableText();
        cantidad.getEditableText();
        fecha.setEnabled(true);
        // fecha_p.setVisibility(View.VISIBLE);
        descripcion.setEnabled(true);
        // descripcion.getEditableText();
        linearLayout.setVisibility(View.VISIBLE);
        fecha.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                final Calendar mcurrentDate = Calendar.getInstance();
                mYear = mcurrentDate.get(Calendar.YEAR);
                mMonth = mcurrentDate.get(Calendar.MONTH);
                mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH);
                final DatePickerDialog mDatePicker = new DatePickerDialog(Detalles_Ingresos_Egresos_Activity.this, new DatePickerDialog.OnDateSetListener() {

                    public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
                        // TODO Auto-generated method stub
                        /*SimpleDateFormat simpledateformat = new SimpleDateFormat("EEEE");
                        Date date = new Date(selectedyear, selectedmonth, selectedday-1);
                        String dayOfWeek = simpledateformat.format(date);
                        fechaCadena=selectedday+"-"+(selectedmonth+1)+"-"+selectedyear;
                        d.setText(dayOfWeek+"," +fechaCadena);*/
                        fechaCadena = selectedyear + "-" + (selectedmonth + 1) + "-" + selectedday;
                        fecha.setText(fechaCadena);
                    }
                }, mYear, mMonth, mDay);
                mDatePicker.setTitle("Selecciona la fecha");
                mDatePicker.show();
            //date=mDay+"-"+mMonth+"-"+mYear;
            }
        });
    }
    return super.onOptionsItemSelected(item);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) DatePickerDialog(android.app.DatePickerDialog) Calendar(java.util.Calendar) DatePicker(android.widget.DatePicker) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

DatePickerDialog (android.app.DatePickerDialog)20 Calendar (java.util.Calendar)12 DatePicker (android.widget.DatePicker)10 TimePickerDialog (android.app.TimePickerDialog)4 DialogInterface (android.content.DialogInterface)4 View (android.view.View)4 AdapterView (android.widget.AdapterView)3 SimpleDateFormat (java.text.SimpleDateFormat)3 AlertDialog (android.app.AlertDialog)2 OnDateSetListener (android.app.DatePickerDialog.OnDateSetListener)2 Intent (android.content.Intent)2 TextView (android.widget.TextView)2 Toast (android.widget.Toast)2 Description (com.github.mikephil.charting.components.Description)2 Entry (com.github.mikephil.charting.data.Entry)2 PieEntry (com.github.mikephil.charting.data.PieEntry)2 Highlight (com.github.mikephil.charting.highlight.Highlight)2 OnChartValueSelectedListener (com.github.mikephil.charting.listener.OnChartValueSelectedListener)2 Date (java.util.Date)2 Test (org.junit.Test)2