List of usage examples for android.app DatePickerDialog show
public void show()
From source file:com.franmontiel.localechanger.sample.SampleFragment.java
@OnClick(R.id.showDatePicker) void onShowDatePickerClick() { Calendar now = Calendar.getInstance(); DatePickerDialog dialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override/* w ww . j a v a 2 s .c o m*/ 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(); }
From source file:com.magizdev.babyoneday.profilewizard.BirthDataFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(com.magizdev.babyoneday.R.layout.fragment_profilewizard_birthdata, container, false);/*from w w w . ja v a 2 s .com*/ ((TextView) rootView.findViewById(android.R.id.title)).setText(mPage.getTitle()); mHeightView = ((TextView) rootView.findViewById(com.magizdev.babyoneday.R.id.profile_height_edittext)); mHeightView.setText(Float.toString(mPage.getData().getFloat(Profile.HEIGHT))); mWeightView = (TextView) rootView.findViewById(com.magizdev.babyoneday.R.id.profile_weight_edittext); mWeightView.setText(Float.toString(mPage.getData().getFloat(Profile.WEIGHT))); mBirthday = (TextView) rootView.findViewById(R.id.profile_birthday); mBirthdayBtn = (ImageButton) rootView.findViewById(com.magizdev.babyoneday.R.id.profile_birthday_set); int intBirthday = mPage.getData().getInt(Profile.BIRTHDAY); calendar = DayUtil.toCalendar(intBirthday); mBirthday.setText(birthdayString + ":" + DayUtil.formatCalendar(calendar)); mBirthdayBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { DatePickerDialog dialog = new DatePickerDialog(getActivity(), BirthDataFragment.this, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); dialog.show(); } }); birthdayString = getActivity().getResources().getString(com.magizdev.babyoneday.R.string.profile_birthday); return rootView; }
From source file:de.langerhans.wallet.ui.ImportKeysQrFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.import_keys_qr_fragment, container); final Intent intent = activity.getIntent(); calendar = Calendar.getInstance(); date = (TextView) view.findViewById(R.id.import_keys_qr_date); final String input = intent.getExtras().getString(ImportKeysQrActivity.INTENT_EXTRA_INPUT); final StringReader sr = new StringReader(input); final BufferedReader keyReader = new BufferedReader(sr); try {/*from ww w.j av a2s.c o m*/ final List<ECKey> keys = WalletUtils.readKeys(keyReader); String privatekeys = new String(); String addresses = new String(); final String pubkey = new Address(Constants.NETWORK_PARAMETERS, keys.get(0).getPubKeyHash()).toString(); long oldest = calendar.getTimeInMillis() / 1000; for (ECKey key : keys) { privatekeys += key.getPrivateKeyEncoded(Constants.NETWORK_PARAMETERS).toString() + "\n"; addresses += new Address(Constants.NETWORK_PARAMETERS, key.getPubKeyHash()).toString() + "\n"; oldest = Math.min(oldest, key.getCreationTimeSeconds()); } TextView privatekey = (TextView) view.findViewById(R.id.import_keys_qr_privatekey); privatekey.setText(privatekeys); TextView address = (TextView) view.findViewById(R.id.import_keys_qr_address); address.setText(addresses); if (oldest == 0) { // If key creation date is not specified oldest = calendar.getTimeInMillis() / 1000; } updateDate(oldest); date.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { DatePickerDialog datePickerDialog = new DatePickerDialog(activity, dateSetListener, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE)); datePickerDialog.show(); } }); importkey = (Button) view.findViewById(R.id.import_keys_qr_importkey); importkey.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { for (ECKey key : keys) { key.setCreationTimeSeconds(calendar.getTimeInMillis() / 1000); } importPrivateKeys(keys); } }); abe = (Button) view.findViewById(R.id.import_keys_qr_abe); abe.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.BLOCKEXPLORER_BASE_URL + "address/" + pubkey))); } }); cancel = (Button) view.findViewById(R.id.import_keys_qr_cancel); cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { activity.finish(); } }); } catch (final IOException x) { new AlertDialog.Builder(activity).setInverseBackgroundForced(true) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(R.string.import_export_keys_dialog_failure_title) .setMessage(getString(R.string.import_keys_dialog_failure, x.getMessage())) .setNeutralButton(R.string.button_dismiss, null).show(); log.info("problem reading private keys", x); } return view; }
From source file:ca.marcmeszaros.papyrus.browser.BooksBrowser.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { switch (requestCode) { // LOAN A BOOK case 1001: // there are sufficient copies of the book to lend if (canLoanBook()) { loanData = data;// w ww . java 2 s .c o m // set default due date final Calendar c = Calendar.getInstance(); c.setTimeInMillis(System.currentTimeMillis() + (1000 * 60 * 60 * 24 * 14)); int mYear = c.get(Calendar.YEAR); int mMonth = c.get(Calendar.MONTH); int mDay = c.get(Calendar.DAY_OF_MONTH); // create the custom dialog title view block LinearLayout linearLayout = (LinearLayout) getLayoutInflater() .inflate(R.layout.datepickerdialog_customtitle_twoline, null); TextView title = (TextView) linearLayout .findViewById(R.id.DatePickerDialog_customTitle_twoline_title); TextView titleDescription = (TextView) linearLayout .findViewById(R.id.DatePickerDialog_customTitle_twoline_description); // set the text title.setText(R.string.AlertDialog_LoanReturnDateDialog_title); titleDescription.setText(R.string.AlertDialog_LoanReturnDateDialog_titleDescription); // create the dialog with the custom header and display it DatePickerDialog dialog = new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay); dialog.setCustomTitle(linearLayout); dialog.show(); } else { // there are no more copies left in the library Toast.makeText(this, getString(R.string.BooksBrowser_toast_allCopiesLentOut), Toast.LENGTH_LONG) .show(); } break; } } else { // gracefully handle failure // Log.w(DEBUG_TAG, "resultWarning: activity result not ok"); } }
From source file:com.adarshahd.indianrailinfo.donate.TrainEnquiry.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.id_btn_date: DatePickerDialog datePickerDialog = new DatePickerDialog(this, this, mCal.get(Calendar.YEAR), mCal.get(Calendar.MONTH), mCal.get(Calendar.DAY_OF_MONTH)); datePickerDialog.show(); break;// w w w . j a va 2s.co m case R.id.id_btn_details: if (!mUtil.isConnected()) { mUtil.showAlert("Alert", "Network unavailable, Please check your network connection."); return; } if (isFormOK()) { ((Button) v).setText("Getting details, please wait . . ."); v.setEnabled(false); if (!searchUsingTrnNumber) { mSrc = mACTFrom.getText().toString().split("- ", 0)[1]; mDst = mACTTo.getText().toString().split("- ", 0)[1]; } new GetTrainDetails().execute(); } else { break; } break; default: return; } }
From source file:de.nico.ha_manager.activities.AddHomework.java
public void setUntil(View v) { DatePickerDialog dpd = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { @Override/*from ww w . jav a 2s. c o m*/ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { date[0] = year; date[1] = monthOfYear; date[2] = dayOfMonth; setTextViewUntil(date); } }, date[0], date[1], date[2]); dpd.show(); }
From source file:com.rsmsa.accapp.ScreenSlidePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.vehicle_one, container, false); tab_one = (EditText) rootView.findViewById(R.id.dob_one); Log.d("vp", "current page " + MainActivity.currentPage); Log.d("vp", "tab text " + tab_one.getText()); /**//from w w w . j ava 2s . c om * Defining all layout items **/ inputFatal = (EditText) rootView.findViewById(R.id.fatal_edit); inputInjuries = (EditText) rootView.findViewById(R.id.injury_edit); inputSimple = (EditText) rootView.findViewById(R.id.simple_edit); inputNotInjured = (EditText) rootView.findViewById(R.id.not_injured_edit); //driver 0ne details surname_one = (EditText) rootView.findViewById(R.id.surname_one); othernames_one = (EditText) rootView.findViewById(R.id.othernames_one); physical_address_one = (EditText) rootView.findViewById(R.id.physical_address_one); address_box_one = (EditText) rootView.findViewById(R.id.address_box_one); national_id_one = (EditText) rootView.findViewById(R.id.national_id_one); phone_no_one = (EditText) rootView.findViewById(R.id.phone_no_one); gender = (RadioGroup) rootView.findViewById(R.id.gender); RadioButton male = (RadioButton) rootView.findViewById(R.id.male); RadioButton female = (RadioButton) rootView.findViewById(R.id.female); nationality_one = (EditText) rootView.findViewById(R.id.nationality_one); license_one = (EditText) rootView.findViewById(R.id.license_one); occupation_one = (EditText) rootView.findViewById(R.id.occupation_one); alcohol_edit = (EditText) rootView.findViewById(R.id.alcohol_edit); drug_edit = (CheckBox) rootView.findViewById(R.id.drug_edit); phone_edit = (CheckBox) rootView.findViewById(R.id.phone_edit); seat_belt_edit = (CheckBox) rootView.findViewById(R.id.seat_belt_edit); //Vehicle one details type_one = (EditText) rootView.findViewById(R.id.type_one); registration_number_one = (EditText) rootView.findViewById(R.id.registration_number_one); //Vehicle one Insurance details company_one = (EditText) rootView.findViewById(R.id.company_one); insurance_type_one = (EditText) rootView.findViewById(R.id.insurance_type_one); insurance_phone = (EditText) rootView.findViewById(R.id.insurance_phone); policy_period_one = (EditText) rootView.findViewById(R.id.policy_period_one); policy_number_one = (EditText) rootView.findViewById(R.id.policy_number_one); repair_amount_one = (EditText) rootView.findViewById(R.id.repair_amount_one); //Vehicle one damage details vehicle = (EditText) rootView.findViewById(R.id.vehicle_title_edit); vehicle_total = (EditText) rootView.findViewById(R.id.vehicle_total_edit); infrastructure = (EditText) rootView.findViewById(R.id.infrastructure_edit); cost = (EditText) rootView.findViewById(R.id.rescue_cost_edit); //Textchange inputFatal.addTextChangedListener(new EditTextWatcher(inputFatal)); inputInjuries.addTextChangedListener(new EditTextWatcher(inputInjuries)); inputSimple.addTextChangedListener(new EditTextWatcher(inputSimple)); inputNotInjured.addTextChangedListener(new EditTextWatcher(inputNotInjured)); surname_one.addTextChangedListener(new EditTextWatcher(surname_one)); othernames_one.addTextChangedListener(new EditTextWatcher(othernames_one)); physical_address_one.addTextChangedListener(new EditTextWatcher(physical_address_one)); address_box_one.addTextChangedListener(new EditTextWatcher(address_box_one)); national_id_one.addTextChangedListener(new EditTextWatcher(national_id_one)); phone_no_one.addTextChangedListener(new EditTextWatcher(phone_no_one)); inputFatal.addTextChangedListener(new EditTextWatcher(inputFatal)); inputInjuries.addTextChangedListener(new EditTextWatcher(inputInjuries)); inputSimple.addTextChangedListener(new EditTextWatcher(inputSimple)); inputNotInjured.addTextChangedListener(new EditTextWatcher(inputNotInjured)); // gender.addTextChangedListener(new EditTextWatcher(gender)); nationality_one.addTextChangedListener(new EditTextWatcher(nationality_one)); license_one.addTextChangedListener(new EditTextWatcher(license_one)); occupation_one.addTextChangedListener(new EditTextWatcher(occupation_one)); alcohol_edit.addTextChangedListener(new EditTextWatcher(alcohol_edit)); //drug_edit.addTextChangedListener(new EditTextWatcher(drug_edit)); //phone_edit.addTextChangedListener(new EditTextWatcher(phone_edit)); //seat_belt_edit.addTextChangedListener(new EditTextWatcher(seat_belt_edit)); type_one.addTextChangedListener(new EditTextWatcher(type_one)); registration_number_one.addTextChangedListener(new EditTextWatcher(registration_number_one)); company_one.addTextChangedListener(new EditTextWatcher(company_one)); insurance_type_one.addTextChangedListener(new EditTextWatcher(insurance_type_one)); insurance_phone.addTextChangedListener(new EditTextWatcher(insurance_phone)); policy_period_one.addTextChangedListener(new EditTextWatcher(policy_period_one)); policy_number_one.addTextChangedListener(new EditTextWatcher(policy_number_one)); repair_amount_one.addTextChangedListener(new EditTextWatcher(repair_amount_one)); vehicle.addTextChangedListener(new EditTextWatcher(vehicle)); vehicle_total.addTextChangedListener(new EditTextWatcher(vehicle_total)); infrastructure.addTextChangedListener(new EditTextWatcher(infrastructure)); cost.addTextChangedListener(new EditTextWatcher(cost)); vehicle_category = (Spinner) rootView.findViewById(R.id.vtype_spinner); vehicle_type = (Button) rootView.findViewById(R.id.vehicle_type_select_button); cal = Calendar.getInstance(); day = cal.get(Calendar.DAY_OF_MONTH); month = cal.get(Calendar.MONTH); year = cal.get(Calendar.YEAR); pickDate = (Button) rootView.findViewById(R.id.date_picker); pickDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), datePickerListener, year, month, day); datePickerDialog.show(); } }); List<String> vehicle_category_list = new ArrayList<String>(); vehicle_category_list.add("Private"); vehicle_category_list.add("Commercial"); vehicle_category_list.add("Government"); vehicle_category_list.add("Emergency"); vehicle_category_list.add("Passenger Service Vehicles"); vehicle_category.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { selectedSpinner = i; if (i == 0) { selectedSpinner = 234; } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); vehicle_type.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getActivity(), VehicleType.class); intent.putExtra("category", selectedSpinner + ""); startActivity(intent); } }); ArrayAdapter<String> atc_adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, vehicle_category_list); atc_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); vehicle_category.setAdapter(atc_adapter); return rootView; }
From source file:org.openlmis.core.view.holder.StockMovementViewHolder.java
private void showDatePickerDialog(final StockMovementViewModel model, final Date previousMovementDate) { final Calendar today = GregorianCalendar.getInstance(); DatePickerDialog dialog = new DatePickerDialog(context, DatePickerDialog.BUTTON_NEUTRAL, new MovementDateListener(model, previousMovementDate), today.get(Calendar.YEAR), today.get(Calendar.MONTH), today.get(Calendar.DAY_OF_MONTH)); dialog.show(); }
From source file:com.rsmsa.accapp.ScreenSlidePageFragmentTwo.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.vehicle_two, container, false); tab_one = (EditText) rootView.findViewById(R.id.dob_one); vehicle_category = (Spinner) rootView.findViewById(R.id.vtype_spinner); vehicle_type = (Button) rootView.findViewById(R.id.vehicle_type_select_button); /**/*from w w w . j av a2 s . c om*/ * Defining all layout items **/ inputFatal = (EditText) rootView.findViewById(R.id.fatal_edit); inputInjuries = (EditText) rootView.findViewById(R.id.injury_edit); inputSimple = (EditText) rootView.findViewById(R.id.simple_edit); inputNotInjured = (EditText) rootView.findViewById(R.id.not_injured_edit); //driver 0ne details surname_one = (EditText) rootView.findViewById(R.id.surname_one); othernames_one = (EditText) rootView.findViewById(R.id.othernames_one); physical_address_one = (EditText) rootView.findViewById(R.id.physical_address_one); address_box_one = (EditText) rootView.findViewById(R.id.address_box_one); national_id_one = (EditText) rootView.findViewById(R.id.national_id_one); phone_no_one = (EditText) rootView.findViewById(R.id.phone_no_one); final RadioButton male = (RadioButton) rootView.findViewById(R.id.male); final RadioButton female = (RadioButton) rootView.findViewById(R.id.female); nationality_one = (EditText) rootView.findViewById(R.id.nationality_one); license_one = (EditText) rootView.findViewById(R.id.license_one); occupation_one = (EditText) rootView.findViewById(R.id.occupation_one); alcohol_edit = (EditText) rootView.findViewById(R.id.alcohol_edit); drug = (CheckBox) rootView.findViewById(R.id.drug_edit); phone_use = (CheckBox) rootView.findViewById(R.id.phone_edit); seat_belt = (CheckBox) rootView.findViewById(R.id.seat_belt_edit); //Vehicle one details type_one = (EditText) rootView.findViewById(R.id.type_one); registration_number_one = (EditText) rootView.findViewById(R.id.registration_number_one); //Vehicle one Insurance details company_one = (EditText) rootView.findViewById(R.id.company_one); insurance_type_one = (EditText) rootView.findViewById(R.id.insurance_type_one); insurance_phone = (EditText) rootView.findViewById(R.id.insurance_phone); policy_period_one = (EditText) rootView.findViewById(R.id.policy_period_one); policy_number_one = (EditText) rootView.findViewById(R.id.policy_number_one); repair_amount_one = (EditText) rootView.findViewById(R.id.repair_amount_one); //Vehicle one damage details vehicle = (EditText) rootView.findViewById(R.id.vehicle_title_edit); vehicle_total = (EditText) rootView.findViewById(R.id.vehicle_total_edit); infrastructure = (EditText) rootView.findViewById(R.id.infrastructure_edit); cost = (EditText) rootView.findViewById(R.id.rescue_cost_edit); /** * getting values of our view elements */ drug.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { MainActivity.V2_drug_edit = "Drugs Use"; } else { MainActivity.V2_drug_edit = " No Drug use"; } } }); phone_use.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { MainActivity.V2_phone_edit = "Was using Phone"; } else { MainActivity.V2_phone_edit = " No phone use"; } } }); seat_belt.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { MainActivity.V2_seat_belt_edit = "Seat belt not fastened"; } else { MainActivity.V2_seat_belt_edit = "Seat belt fastened"; } } }); male.setChecked(true); // Fatal.setChecked(true); male.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { female.setChecked(false); MainActivity.V2_gender = "male"; } } }); female.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { male.setChecked(false); MainActivity.V2_gender = "female"; } } }); cal = Calendar.getInstance(); day = cal.get(Calendar.DAY_OF_MONTH); month = cal.get(Calendar.MONTH); year = cal.get(Calendar.YEAR); pickDate = (Button) rootView.findViewById(R.id.date_picker); pickDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), datePickerListener, year, month, day); datePickerDialog.show(); } }); List<String> vehicle_category_list = new ArrayList<String>(); vehicle_category_list.add("Private"); vehicle_category_list.add("Commercial"); vehicle_category_list.add("Government"); vehicle_category_list.add("Emergency"); vehicle_category_list.add("Passenger Service Vehicles"); vehicle_category.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { selectedSpinner = i; } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); vehicle_type.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getActivity(), VehicleType.class); intent.putExtra("category", selectedSpinner + ""); startActivity(intent); } }); ArrayAdapter<String> atc_adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, vehicle_category_list); atc_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); vehicle_category.setAdapter(atc_adapter); return rootView; }
From source file:net.naonedbus.fragment.impl.ItineraireFragment.java
private void showDatePicker() { final DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, mDateTime.getYear(), mDateTime.getMonthOfYear() - 1, mDateTime.getDayOfMonth()); dialog.show(); }