use of android.app.DatePickerDialog in project MyDiary by erttyy8821.
the class DatePickerFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Calendar calendar;
savedTime = getArguments().getLong("savedTime", -1);
calendar = Calendar.getInstance();
if (savedTime != -1) {
calendar.setTimeInMillis(savedTime);
}
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(getActivity(), ThemeManager.getInstance().getPickerStyle(), onDateSetListener, year, month, day);
}
use of android.app.DatePickerDialog in project AdMoney by ErnestoGonAr.
the class PagoRecurrenteActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pagos_recurrentes);
bd = new BDHandlerAM(this);
guardar = (Button) findViewById(R.id.PRguardar);
salir = (Button) findViewById(R.id.PRsalir);
n = (EditText) findViewById(R.id.nombre_pago);
cant = (EditText) findViewById(R.id.PRcantidad);
sp = (Spinner) findViewById(R.id.spinner_repetir);
frecuencia = sp.getSelectedItemPosition();
fecha = (DatePicker) findViewById(R.id.datepicker);
tx = (TextView) findViewById(R.id.textoFrecuencia);
d = (EditText) findViewById(R.id.txtdia);
fecha.setVisibility(View.GONE);
d.setVisibility(View.GONE);
d.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(PagoRecurrenteActivity.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 = selectedyear + "-" + (selectedmonth + 1) + "-" + selectedday;
d.setText(dayOfWeek + "," + fechaCadena);
}
}, mYear, mMonth, mDay);
mDatePicker.setTitle("Selecciona la fecha");
mDatePicker.show();
date = mDay + "-" + mMonth + "-" + mYear;
}
});
d.setText(date);
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (sp.getSelectedItemPosition() == 0) {
fecha.setVisibility(View.VISIBLE);
d.setVisibility(View.GONE);
}
if (sp.getSelectedItemPosition() == 1) {
fecha.setVisibility(View.VISIBLE);
d.setVisibility(View.GONE);
}
if (sp.getSelectedItemPosition() == 2) {
d.setVisibility(View.VISIBLE);
fecha.setVisibility(View.GONE);
}
if (sp.getSelectedItemPosition() == 3) {
fecha.setVisibility(View.VISIBLE);
d.setVisibility(View.GONE);
}
if (sp.getSelectedItemPosition() == 4) {
fecha.setVisibility(View.VISIBLE);
d.setVisibility(View.GONE);
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
fechaCadena = fecha.getYear() + "-" + (fecha.getMonth() + 1) + "-" + fecha.getDayOfMonth();
fecha.init(fecha.getYear(), fecha.getMonth(), fecha.getDayOfMonth(), new DatePicker.OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker datePicker, int year, int month, int dayOfMonth) {
fechaCadena = fecha.getYear() + "-" + (fecha.getMonth() + 1) + "-" + fecha.getDayOfMonth();
}
});
salir.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
guardar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (validar()) {
if (cant.getText().toString().equals("")) {
cant.setText("0.0");
}
try {
cantidad = Float.parseFloat(cant.getText().toString());
if (!validar2(cantidad)) {
return;
}
} catch (NumberFormatException e) {
}
nombre = n.getText().toString();
bd.insertarRecurrentes(nombre, cantidad, fechaCadena, frecuencia);
int idr = bd.ultIdRec();
new AgregarNotf().agregarNotf(getApplicationContext(), nombre, cantidad, fechaCadena, frecuencia, idr);
Intent i = new Intent(PagoRecurrenteActivity.this, MainActivity.class);
startActivity(i);
}
}
});
}
use of android.app.DatePickerDialog in project material-calendarview by prolificinteractive.
the class DynamicSettersActivity method showDatePickerDialog.
public static void showDatePickerDialog(Context context, CalendarDay day, DatePickerDialog.OnDateSetListener callback) {
if (day == null) {
day = CalendarDay.today();
}
DatePickerDialog dialog = new DatePickerDialog(context, 0, callback, day.getYear(), day.getMonth(), day.getDay());
dialog.show();
}
use of android.app.DatePickerDialog in project robolectric by robolectric.
the class ShadowDatePickerDialogTest method savesTheCallback.
@Test
public void savesTheCallback() {
DatePickerDialog.OnDateSetListener expectedDateSetListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
// ignored
}
};
DatePickerDialog datePickerDialog = new DatePickerDialog(RuntimeEnvironment.application, expectedDateSetListener, 2012, 6, 7);
ShadowDatePickerDialog shadowDatePickerDialog = shadowOf(datePickerDialog);
assertThat(shadowDatePickerDialog.getOnDateSetListenerCallback()).isEqualTo(expectedDateSetListener);
}
use of android.app.DatePickerDialog in project diary by billthefarmer.
the class DatePickerFragment method onCreateDialog.
// onCreateDialog
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Bundle bundle = getArguments();
long time = bundle.getLong(Diary.DATE);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time);
// Create a new instance of DatePickerDialog
DatePickerDialog dialog = new DatePickerDialog(getActivity(), (DatePickerDialog.OnDateSetListener) getActivity(), calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE));
// Set up the date picker
if (Build.VERSION.SDK_INT < Diary.VERSION_NOUGAT) {
DatePicker picker = dialog.getDatePicker();
Configuration config = getResources().getConfiguration();
switch(config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) {
case Configuration.SCREENLAYOUT_SIZE_SMALL:
picker.setCalendarViewShown(true);
picker.setSpinnersShown(false);
break;
case Configuration.SCREENLAYOUT_SIZE_NORMAL:
switch(config.orientation) {
case Configuration.ORIENTATION_PORTRAIT:
picker.setCalendarViewShown(true);
picker.setSpinnersShown(false);
break;
case Configuration.ORIENTATION_LANDSCAPE:
picker.setCalendarViewShown(true);
break;
}
break;
default:
picker.setCalendarViewShown(true);
break;
}
}
return dialog;
}
Aggregations