List of usage examples for android.app TimePickerDialog TimePickerDialog
public TimePickerDialog(Context context, OnTimeSetListener listener, int hourOfDay, int minute, boolean is24HourView)
From source file:com.rsmsa.accapp.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_drawer); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); gridView = (ListView) findViewById(R.id.headergridview); /**//from w ww . j ava2s . c o m * Temporary header */ if (!hasheader) { tempHeader = (View) getLayoutInflater().inflate(R.layout.temp, null); gridView.addHeaderView(tempHeader); gridView.setAdapter(new gridViewAdapter(MainActivity.this)); hasheader = true; tempFlag = true; } imgPreview = (ImageView) tempHeader.findViewById(R.id.imgPreview); videoPreview = (VideoView) tempHeader.findViewById(R.id.videoPreview); btnCapturePicture = (ImageButton) tempHeader.findViewById(R.id.btnCapturePicture); btnRecordVideo = (ImageButton) tempHeader.findViewById(R.id.btnCaptureVideo); /** * Capture image button click event */ btnCapturePicture.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // capture picture captureImage(); } }); /** * Record video button click event */ btnRecordVideo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // record video recordVideo(); } }); // Checking camera availability if (!isDeviceSupportCamera()) { Toast.makeText(getApplicationContext(), "Sorry! Your device doesn't support camera", Toast.LENGTH_LONG) .show(); // will close the app if the device does't have camera finish(); } //get GPS location SetLocation = (Button) tempHeader.findViewById(R.id.btnLoc); SetLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // create class object gps = new GPSTracker(MainActivity.this); // check if GPS enabled if (gps.canGetLocation()) { double latitude = gps.getLatitude(); double longitude = gps.getLongitude(); //location text view TextView location = (TextView) tempHeader.findViewById(R.id.loc); location.setText("Lat: " + latitude + "Long: " + longitude); } else { // can't get location // GPS or Network is not enabled // Ask user to enable GPS/network in settings gps.showSettingsAlert(); } } }); /** * header instance */ header = (View) getLayoutInflater().inflate(R.layout.activity_accident, null); /** * Defining all layout items **/ inputReg = (EditText) header.findViewById(R.id.reg_ref); inputFatal = (EditText) header.findViewById(R.id.fatal_edit); inputInjuries = (EditText) header.findViewById(R.id.injury_edit); inputSimple = (EditText) header.findViewById(R.id.simple_edit); damage = (EditText) header.findViewById(R.id.not_injured_edit); area_name = (EditText) header.findViewById(R.id.name); district = (EditText) header.findViewById(R.id.district); region = (EditText) header.findViewById(R.id.city); road_name = (EditText) header.findViewById(R.id.road_name); road_no = (EditText) header.findViewById(R.id.road_number); road_mark = (EditText) header.findViewById(R.id.road_mark); intersection_name = (EditText) header.findViewById(R.id.intersection_name); intersection_no = (EditText) header.findViewById(R.id.intersection_number); intersection_mark = (EditText) header.findViewById(R.id.intersection_mark); mDate = (EditText) header.findViewById(R.id.date); mTime = (EditText) header.findViewById(R.id.time); //Textchanges inputReg.addTextChangedListener(new EditTextWatcher(inputReg)); inputFatal.addTextChangedListener(new EditTextWatcher(inputFatal)); inputInjuries.addTextChangedListener(new EditTextWatcher(inputInjuries)); inputSimple.addTextChangedListener(new EditTextWatcher(inputSimple)); damage.addTextChangedListener(new EditTextWatcher(damage)); area_name.addTextChangedListener(new EditTextWatcher(area_name)); district.addTextChangedListener(new EditTextWatcher(district)); region.addTextChangedListener(new EditTextWatcher(region)); mDate.addTextChangedListener(new EditTextWatcher(mDate)); mTime.addTextChangedListener(new EditTextWatcher(mTime)); road_name.addTextChangedListener(new EditTextWatcher(road_name)); road_no.addTextChangedListener(new EditTextWatcher(road_no)); road_mark.addTextChangedListener(new EditTextWatcher(road_mark)); intersection_name.addTextChangedListener(new EditTextWatcher(intersection_name)); intersection_no.addTextChangedListener(new EditTextWatcher(intersection_no)); intersection_mark.addTextChangedListener(new EditTextWatcher(intersection_mark)); cal = Calendar.getInstance(); day = cal.get(Calendar.DAY_OF_MONTH); month = cal.get(Calendar.MONTH); year = cal.get(Calendar.YEAR); hour = cal.get(Calendar.HOUR_OF_DAY); min = cal.get(Calendar.MINUTE); datePicker = (Button) header.findViewById(R.id.date_picker); datePicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DatePickerDialog datePickerDialog = new DatePickerDialog(MainActivity.this, datePickerListener, year, month, day); datePickerDialog.show(); } }); timePicker = (Button) header.findViewById(R.id.time_picker); timePicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { TimePickerDialog timePickerDialog = new TimePickerDialog(MainActivity.this, timePickerListener, hour, min, true); timePickerDialog.show(); } }); // set a custom shadow that overlays the main content when the drawer // opens mDrawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); _initMenu(); mDrawerToggle = new CustomActionBarDrawerToggle(this, mDrawer); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent passenger = new Intent(MainActivity.this, Passenger.class); startActivity(passenger); } }); mDrawer.setDrawerListener(mDrawerToggle); /** * instantiate ViewPager */ mPager = (AutoScrollViewPager) header.findViewById(R.id.pager); mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager()); mPager.setPageTransformer(true, new DepthPageTransformer()); mPager.setAdapter(mPagerAdapter); PageListener pageListener = new PageListener(); mPager.setOnPageChangeListener(pageListener); }
From source file:oss.ridendivideapp.TakeRideActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_DATE: return new DatePickerDialog(this, new OnDateSetListener() { @Override//from ww w . java 2 s .c om public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { dateTime.set(year, monthOfYear, dayOfMonth); datePicker.setText(dateFormatter.format(dateTime.getTime())); } }, dateTime.get(Calendar.YEAR), dateTime.get(Calendar.MONTH), dateTime.get(Calendar.DAY_OF_MONTH)); case DIALOG_TIME: return new TimePickerDialog(this, new OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { dateTime.set(Calendar.HOUR_OF_DAY, hourOfDay); dateTime.set(Calendar.MINUTE, minute); timePicker.setText(timeFormatter.format(dateTime.getTime())); } }, dateTime.get(Calendar.HOUR_OF_DAY), dateTime.get(Calendar.MINUTE), false); } return null; }
From source file:tw.com.geminihsu.app01.fragment.Fragment_PickUpMerchandiseStation.java
private void setLister() { timePicker = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int hourOfDay, int minute) { }//from ww w . j a v a 2 s. c om }; timerPicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new TimePickerDialog(getActivity(), timePicker, 24, 59, true).show(); } }); departure.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity()); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.select_dialog_item); arrayAdapter.add(getString(R.string.pop_map_option1)); arrayAdapter.add(getString(R.string.pop_map_option2)); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String strName = arrayAdapter.getItem(which); switch (which) { case 0: Intent map = new Intent(getActivity(), OrderMapActivity.class); Bundle b = new Bundle(); b.putInt(Constants.ARG_POSITION, Constants.DEPARTURE_QUERY_GPS); map.putExtras(b); startActivityForResult(map, Constants.DEPARTURE_QUERY_GPS); break; case 1: Intent page = new Intent(getActivity(), BookmarksMapListActivity.class); Bundle flag = new Bundle(); flag.putInt(Constants.ARG_POSITION, Constants.DEPARTURE_QUERY_BOOKMARK); page.putExtras(flag); startActivityForResult(page, Constants.DEPARTURE_QUERY_BOOKMARK); break; } } }); builderSingle.show(); } }); stop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity()); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.select_dialog_item); arrayAdapter.add(getString(R.string.pop_map_option1)); arrayAdapter.add(getString(R.string.pop_map_option2)); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String strName = arrayAdapter.getItem(which); switch (which) { case 0: Intent map = new Intent(getActivity(), OrderMapActivity.class); Bundle b = new Bundle(); b.putInt(Constants.ARG_POSITION, Constants.STOP_QUERY_GPS); map.putExtras(b); startActivityForResult(map, Constants.STOP_QUERY_GPS); break; case 1: Intent page = new Intent(getActivity(), BookmarksMapListActivity.class); Bundle flag = new Bundle(); flag.putInt(Constants.ARG_POSITION, Constants.STOP_QUERY_BOOKMARK); page.putExtras(flag); startActivityForResult(page, Constants.STOP_QUERY_BOOKMARK); break; } } }); builderSingle.show(); } }); destination.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity()); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.select_dialog_item); arrayAdapter.add(getString(R.string.pop_map_option1)); arrayAdapter.add(getString(R.string.pop_map_option2)); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String strName = arrayAdapter.getItem(which); switch (which) { case 0: Intent map = new Intent(getActivity(), OrderMapActivity.class); Bundle b = new Bundle(); b.putInt(Constants.ARG_POSITION, Constants.DESTINATION_QUERY_GPS); map.putExtras(b); startActivityForResult(map, Constants.DESTINATION_QUERY_GPS); break; case 1: Intent page = new Intent(getActivity(), BookmarksMapListActivity.class); Bundle flag = new Bundle(); flag.putInt(Constants.ARG_POSITION, Constants.DESTINATION_QUERY_BOOKMARK); page.putExtras(flag); startActivityForResult(page, Constants.DESTINATION_QUERY_BOOKMARK); break; } } }); builderSingle.show(); } }); spec.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // custom dialog final Dialog dialog = new Dialog(getActivity()); dialog.setContentView(R.layout.client_take_ride_selectspec_requirement); dialog.setTitle(getString(R.string.txt_take_spec)); Button cancel = (Button) dialog.findViewById(R.id.button_category_ok); //dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // set the custom dialog components - text, image and button ListView requirement = (ListView) dialog.findViewById(R.id.listViewDialog); getDataFromDB(); listViewAdapter = new ClientTakeRideSelectSpecListItemAdapter(getActivity(), 0, mCommentListData); requirement.setAdapter(listViewAdapter); listViewAdapter.notifyDataSetChanged(); dialog.show(); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); } }); } }); spinner_dork_location_destination.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) { currentLocation = tainStationList.get(position); destination_detail = new LocationAddress(); destination_detail.setLongitude(Double.parseDouble(currentLocation.getLng())); destination_detail.setLatitude(Double.parseDouble(currentLocation.getLat())); destination_detail.setAddress(currentLocation.getStreetAddress().substring(3, currentLocation.getStreetAddress().length())); destination_detail.setLocation(currentLocation.getLocation()); destination_detail.setZipCode(currentLocation.getStreetAddress().substring(0, 3)); destination_detail.setCountryName("Taiwan"); destination_detail.setLocality(currentLocation.getStreetAddress()); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); spinner_dork_location_departure.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) { currentLocation = tainStationList.get(position); departure_detail = new LocationAddress(); departure_detail.setLongitude(Double.parseDouble(currentLocation.getLng())); departure_detail.setLatitude(Double.parseDouble(currentLocation.getLat())); departure_detail.setAddress(currentLocation.getStreetAddress().substring(3, currentLocation.getStreetAddress().length())); departure_detail.setLocation(currentLocation.getLocation()); departure_detail.setZipCode(currentLocation.getStreetAddress().substring(0, 3)); departure_detail.setCountryName("Taiwan"); departure_detail.setLocality(currentLocation.getStreetAddress()); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); }
From source file:com.sourcey.materiallogindemo.MainActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case TIME_DIALOG_ID: return new TimePickerDialog(this, mTimeSetListener, mHour, mMinute, false); }// ww w .j av a2 s. c o m return null; }
From source file:oss.ridendivideapp.PlacesAutoCompleteActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_DATE: return new DatePickerDialog(this, new OnDateSetListener() { /* Code to set/get date in a dialog box */ @Override/*from w w w. j a v a 2s. c o m*/ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { dateTime.set(year, monthOfYear, dayOfMonth); datePicker.setText(dateFormatter.format(dateTime.getTime())); } }, dateTime.get(Calendar.YEAR), dateTime.get(Calendar.MONTH), dateTime.get(Calendar.DAY_OF_MONTH)); case DIALOG_TIME: return new TimePickerDialog(this, new OnTimeSetListener() { /* Code to set/get time in a dialog box */ @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { dateTime.set(Calendar.HOUR_OF_DAY, hourOfDay); dateTime.set(Calendar.MINUTE, minute); timePicker.setText(timeFormatter.format(dateTime.getTime())); } }, dateTime.get(Calendar.HOUR_OF_DAY), dateTime.get(Calendar.MINUTE), false); } return null; }
From source file:com.ushahidi.android.app.ui.phone.AddReportActivity.java
/** * Create various dialog//from w ww.j av a2 s. co m */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddReportActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_MULTIPLE_CATEGORY: { if (showCategories() != null) { return new AlertDialog.Builder(this).setTitle(R.string.choose_categories) .setMultiChoiceItems(showCategories(), setCheckedCategories(), new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { // see if categories have previously if (isChecked) { mVectorCategories.add(mCategoriesId.get(whichButton)); mError = false; } else { mVectorCategories.remove(mCategoriesId.get(whichButton)); } setSelectedCategories(mVectorCategories); } }) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked Yes so do some stuff */ } }).create(); } } case TIME_DIALOG_ID: return new TimePickerDialog(this, mTimeSetListener, mCalendar.get(Calendar.HOUR), mCalendar.get(Calendar.MINUTE), false); case DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH)); case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete report deleteReport(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:auribises.com.visitorbook.Activites.AdminEntryActivity.java
public void showTimePicker(View view) { Calendar calendar = Calendar.getInstance(); int hh = calendar.get(Calendar.HOUR_OF_DAY); int mm = calendar.get(Calendar.MINUTE); timePickerDialog = new TimePickerDialog(this, timeSetListener, hh, mm, true); timePickerDialog.show();/*from ww w . java2s . co m*/ }
From source file:foam.littlej.android.app.ui.phone.AddReportActivity.java
/** * Create various dialog/* ww w . ja va 2 s. c om*/ */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddReportActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_MULTIPLE_CATEGORY: { if (showCategories() != null) { return new AlertDialog.Builder(this).setTitle(R.string.choose_categories) .setMultiChoiceItems(showCategories(), setCheckedCategories(), new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { // see if categories have previously if (isChecked) { mVectorCategories.add(mCategoriesId.get(whichButton)); mError = false; } else { mVectorCategories.remove(mCategoriesId.get(whichButton)); } setSelectedCategories(mVectorCategories); } }) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked Yes so do some stuff */ } }).create(); } } case TIME_DIALOG_ID: return new TimePickerDialog(this, mTimeSetListener, mCalendar.get(Calendar.HOUR), mCalendar.get(Calendar.MINUTE), false); case DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH)); case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { new DiscardTask(AddReportActivity.this).execute((String) null); finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete report deleteReport(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:com.speed.traquer.app.TraqComplaintTaxi.java
public void timeOnClick(View view) { new TimePickerDialog(TraqComplaintTaxi.this, time, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), false).show();//from w w w . jav a2s . c o m }
From source file:pl.bcichecki.rms.client.android.activities.EditEventActivity.java
private void showEndsOnTimeDialog() { Calendar endTimeCalendar = Calendar.getInstance(); endTimeCalendar.setTime(endDate);//from w w w .ja v a 2 s. c om boolean is24HourFormat = android.text.format.DateFormat.is24HourFormat(context); OnTimeSetListener onTimeSetListener = new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { endDate = DateUtils.setHours(endDate, hourOfDay); endDate = DateUtils.setMinutes(endDate, minute); updateEndDateButtons(); } }; TimePickerDialog timePickerDialog = new TimePickerDialog(context, onTimeSetListener, endTimeCalendar.get(Calendar.HOUR_OF_DAY), endTimeCalendar.get(Calendar.MINUTE), is24HourFormat); timePickerDialog.setTitle(R.string.activity_edit_event_pick_end_time); timePickerDialog.show(); }