Example usage for android.app DatePickerDialog DatePickerDialog

List of usage examples for android.app DatePickerDialog DatePickerDialog

Introduction

In this page you can find the example usage for android.app DatePickerDialog DatePickerDialog.

Prototype

public DatePickerDialog(@NonNull Context context, @Nullable OnDateSetListener listener, int year, int month,
        int dayOfMonth) 

Source Link

Document

Creates a new date picker dialog for the specified date using the parent context's default date picker dialog theme.

Usage

From source file:org.irmacard.cardemu.selfenrol.EnrollSelectActivity.java

public void onDateTouch(View v) {
    final EditText dateView = (EditText) v;
    final String name = v.getId() == R.id.dob_edittext ? "dob" : "doe";
    Long current = settings.getLong("enroll_bac_" + name, 0);

    final Calendar c = Calendar.getInstance();
    if (current != 0)
        c.setTimeInMillis(current);//from   ww  w  . j  a  v  a 2  s .c o m

    int currentYear = c.get(Calendar.YEAR);
    int currentMonth = c.get(Calendar.MONTH);
    int currentDay = c.get(Calendar.DAY_OF_MONTH);

    DatePickerDialog dpd = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar date = new GregorianCalendar(year, monthOfYear, dayOfMonth);
            setDateEditText(dateView, date);
        }
    }, currentYear, currentMonth, currentDay);
    dpd.show();
}

From source file:com.example.moneymeterexample.AddExpenseActivity.java

protected Dialog onCreateDialog(int id) {

    switch (id) {
    case DATE_DIALOG_ID:
        return new DatePickerDialog(this, pDateSetListener, mYear, mMonth, mDay);

    case NEW_CATEGORY_ID:
        AlertDialog.Builder new_cat_dialog = new AlertDialog.Builder(this);
        new_cat_dialog.setMessage("Enter the name of new category");
        new_cat_dialog.setTitle("New Category");
        final EditText new_cat_txt = new EditText(this);
        new_cat_dialog.setView(new_cat_txt);
        new_cat_dialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {

            @Override/*from  w w  w. j  av a  2s  .co m*/
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                String cat = new_cat_txt.getText().toString();

                String last = cat_list.remove((cat_list.size()) - 1);
                cat_list.add(cat);
                cat_list.add(last);
                ((BaseAdapter) category.getAdapter()).notifyDataSetChanged();

            }
        });
        new_cat_dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                dialog.cancel();

            }
        });

        return new_cat_dialog.create();

    case DELETE_CONFIRM_ID:
        AlertDialog.Builder delete_dialog = new AlertDialog.Builder(this);
        delete_dialog.setMessage("Are you sure you want to delete this entry?");
        delete_dialog.setTitle("Delete Confirmation");
        delete_dialog.setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                deleteRecord();
                amt.setText("");
                date.setText("");
                cat_list.remove(category.getSelectedItem().toString());
                ((BaseAdapter) category.getAdapter()).notifyDataSetChanged();
                notes.setText("");

            }
        });
        delete_dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                dialog.cancel();

            }
        });

        return delete_dialog.create();

    }
    return null;
}

From source file:com.owncloud.android.ui.activity.ContactsPreferenceActivity.java

public void openDate(View v) {
    String backupFolderString = getResources().getString(R.string.contacts_backup_folder)
            + OCFile.PATH_SEPARATOR;/*from   ww w .  j  a v a2s  .  c  o  m*/
    OCFile backupFolder = getStorageManager().getFileByPath(backupFolderString);

    Vector<OCFile> backupFiles = getStorageManager().getFolderContent(backupFolder, false);

    Collections.sort(backupFiles, new Comparator<OCFile>() {
        @Override
        public int compare(OCFile o1, OCFile o2) {
            if (o1.getModificationTimestamp() == o2.getModificationTimestamp()) {
                return 0;
            }

            if (o1.getModificationTimestamp() > o2.getModificationTimestamp()) {
                return 1;
            } else {
                return -1;
            }
        }
    });

    Calendar cal = Calendar.getInstance();
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH) + 1;
    int day = cal.get(Calendar.DAY_OF_MONTH);

    DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
            String backupFolderString = getResources().getString(R.string.contacts_backup_folder)
                    + OCFile.PATH_SEPARATOR;
            OCFile backupFolder = getStorageManager().getFileByPath(backupFolderString);
            Vector<OCFile> backupFiles = getStorageManager().getFolderContent(backupFolder, false);

            // find file with modification with date and time between 00:00 and 23:59
            // if more than one file exists, take oldest
            Calendar date = Calendar.getInstance();
            date.set(year, month, dayOfMonth);

            // start
            date.set(Calendar.HOUR, 0);
            date.set(Calendar.MINUTE, 0);
            date.set(Calendar.SECOND, 1);
            date.set(Calendar.MILLISECOND, 0);
            date.set(Calendar.AM_PM, Calendar.AM);
            Long start = date.getTimeInMillis();

            // end
            date.set(Calendar.HOUR, 23);
            date.set(Calendar.MINUTE, 59);
            date.set(Calendar.SECOND, 59);
            Long end = date.getTimeInMillis();

            OCFile backupToRestore = null;

            for (OCFile file : backupFiles) {
                if (start < file.getModificationTimestamp() && end > file.getModificationTimestamp()) {
                    if (backupToRestore == null) {
                        backupToRestore = file;
                    } else if (backupToRestore.getModificationTimestamp() < file.getModificationTimestamp()) {
                        backupToRestore = file;
                    }
                }
            }

            if (backupToRestore != null) {
                Fragment contactListFragment = ContactListFragment.newInstance(backupToRestore, getAccount());

                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.replace(R.id.contacts_linear_layout, contactListFragment);
                transaction.commit();
            } else {
                Toast.makeText(ContactsPreferenceActivity.this, R.string.contacts_preferences_no_file_found,
                        Toast.LENGTH_SHORT).show();
            }
        }
    };

    DatePickerDialog datePickerDialog = new DatePickerDialog(this, dateSetListener, year, month, day);
    datePickerDialog.getDatePicker().setMaxDate(backupFiles.lastElement().getModificationTimestamp());
    datePickerDialog.getDatePicker().setMinDate(backupFiles.firstElement().getModificationTimestamp());

    datePickerDialog.show();
}

From source file:rta.ae.sharekni.RegisterVehicle.java

@Override
protected Dialog onCreateDialog(int id) {
    if (id == DILOG_ID) {
        DatePickerDialog dp = new DatePickerDialog(this, dPickerListener, year_x, month_x, day_x);
        DatePicker d = dp.getDatePicker();
        d.setMaxDate(cal.getTimeInMillis());
        return dp;
    }//from www. j a  va 2 s .c  o  m
    return null;
}

From source file:org.mythdroid.activities.Guide.java

@Override
public Dialog onCreateDialog(int id) {

    switch (id) {

    case DIALOG_DATE:
        return new DatePickerDialog(this, new OnDateSetListener() {
            private int Year = -1, Month = -1, Day = -1;

            @Override//from w  w  w  .  j ava 2  s  .c  o  m
            public void onDateSet(DatePicker view, int year, int month, int day) {
                if (year == Year && month == Month && day == Day)
                    return;
                Year = year;
                Month = month;
                Day = day;
                now.setYear(year - 1900);
                now.setMonth(month);
                now.setDate(day);
                displayGuide(now);
            }
        }, now.getYear() + 1900, now.getMonth(), now.getDate());

    case DIALOG_TIME:
        return new TimePickerDialog(this, new OnTimeSetListener() {
            private int Hour = -1, Min = -1;

            @Override
            public void onTimeSet(TimePicker view, int hour, int min) {
                if (hour == Hour && min == Min)
                    return;
                Hour = hour;
                Min = min;
                now.setHours(hour);
                now.setMinutes(min);
                displayGuide(now);
            }
        }, now.getHours(), now.getMinutes(), true);

    default:
        return super.onCreateDialog(id);

    }

}

From source file:de.spiritcroc.ownlog.ui.fragment.LogItemEditFragment.java

@Override
public void onClick(View view) {
    if (view == mEditTime) {
        new DatePickerDialog(getActivity(), this, mTime.get(Calendar.YEAR), mTime.get(Calendar.MONTH),
                mTime.get(Calendar.DAY_OF_MONTH)).show();
    }/*w  ww  .ja  va2  s  .  co  m*/
}

From source file:ivl.android.moneybalance.ExpenseEditorActivity.java

private void pickDate() {
    final DatePickerDialog.OnDateSetListener onDateSet = new DatePickerDialog.OnDateSetListener() {
        @Override//from   w w  w . j a v a  2  s . c  om
        public void onDateSet(DatePicker view, int year, int month, int day) {
            Calendar date = Calendar.getInstance();
            date.clear();
            date.set(year, month, day);
            expense.setDate(date);
            updateDate();
        }
    };

    DialogFragment fragment = new DialogFragment() {
        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            Calendar date = expense.getDate();
            int year = date.get(Calendar.YEAR);
            int month = date.get(Calendar.MONTH);
            int day = date.get(Calendar.DAY_OF_MONTH);
            return new DatePickerDialog(getActivity(), onDateSet, year, month, day);
        }
    };
    fragment.show(getSupportFragmentManager(), "datePicker");
}

From source file:com.abeo.tia.noordin.ProcessCaseLoanPrincipal.java

@Override
public void onClick(View view) {
    if (view == details_btn) {
        Intent to_purchaser = new Intent(ProcessCaseLoanPrincipal.this, ProcessCaseDetails.class);
        startActivity(to_purchaser);/*www .j a v  a  2s.  c  o  m*/
    }
    if (view == purchaser_btn) {
        Intent to_purchaser = new Intent(ProcessCaseLoanPrincipal.this, ProcessCasePurchaser.class);
        startActivity(to_purchaser);
    }
    if (view == vendor_btn) {
        Intent to_vendor = new Intent(ProcessCaseLoanPrincipal.this, ProcessCaseVendor.class);
        startActivity(to_vendor);
    }
    if (view == property_btn) {
        Intent to_loan_pricipal = new Intent(ProcessCaseLoanPrincipal.this, ProcessCaseProperty.class);
        startActivity(to_loan_pricipal);
    }

    if (view == loan_subsidary_btn) {
        Intent to_loan_subsidiary = new Intent(ProcessCaseLoanPrincipal.this, ProcesscaseLoanSubsidiary.class);
        startActivity(to_loan_subsidiary);
    }
    if (view == process_btn) {
        Intent to_loan_subsidiary = new Intent(ProcessCaseLoanPrincipal.this, ProcessCaseProcessTab.class);
        startActivity(to_loan_subsidiary);
    }
    if (view == walkin) {
        Intent i = new Intent(ProcessCaseLoanPrincipal.this, WalkInActivity.class);
        startActivity(i);
    }

    if (view == req_for_redemption) {
        new DatePickerDialog(ProcessCaseLoanPrincipal.this, req_for_redemption1, myCalendar.get(Calendar.YEAR),
                myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (view == bank_instr_date) {
        new DatePickerDialog(ProcessCaseLoanPrincipal.this, bank_instr_date1, myCalendar.get(Calendar.YEAR),
                myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (view == red_state_date) {
        new DatePickerDialog(ProcessCaseLoanPrincipal.this, red_state_date1, myCalendar.get(Calendar.YEAR),
                myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (view == red_payment_date) {
        new DatePickerDialog(ProcessCaseLoanPrincipal.this, red_payment_date1, myCalendar.get(Calendar.YEAR),
                myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (view == letter_offer_date) {
        new DatePickerDialog(ProcessCaseLoanPrincipal.this, letter_offer_date1, myCalendar.get(Calendar.YEAR),
                myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (view == confirm_btn) {
        try {
            confirm_allvalues_btn();
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

From source file:tw.com.geminihsu.app01.fragment.Fragment_PickUpTrain.java

private void setLister() {

    calendar = Calendar.getInstance();
    timePicker = new TimePickerDialog.OnTimeSetListener() {
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

        }/*from  w  w w  .ja v  a2s  .  c  om*/
    };
    timerPicker.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new TimePickerDialog(getActivity(), timePicker, 24, 59, true).show();
        }
    });
    datePicker = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
            date.setText(dayOfMonth + "/" + (month + 1) + "/" + year);
        }

    };
    btn_datePicker.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new DatePickerDialog(getActivity(), datePicker, calendar.get(Calendar.YEAR),
                    calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)).show();
        }
    });

    radioGroup_orderTimetype.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == reservation.getId()) {
                linearLayout_date_picker.setVisibility(View.VISIBLE);
                linearLayout_time_picker.setVisibility(View.GONE);
            } else {
                linearLayout_date_picker.setVisibility(View.GONE);
                linearLayout_time_picker.setVisibility(View.VISIBLE);
            }
        }
    });

    radiogroup_destination_station.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == thsrStation.getId()) {
                getLocationFromDB("?");
            } else {

                getLocationFromDB("?");
            }
        }
    });

    radiogroup_leave_location.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == departure_thsr_train.getId()) {
                getLocationFromDB("?");
            } else {

                getLocationFromDB("?");
            }
        }
    });
    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();
        }
    });

    getDataFromDB();
    linearLayout_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_cancel);
            Button ok = (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);

            requirement.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

                    ClientTakeRideSelectSpecListItem item = mCommentListData.get(position);
                    item.check = !item.check;
                    mCommentListData.set(position, item);
                    listViewAdapter.notifyDataSetChanged();
                }
            });

            if (listViewAdapter == null) {
                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();
                }
            });

            String require;
            ok.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    String require = "";
                    for (ClientTakeRideSelectSpecListItem item : mCommentListData) {
                        if (item.check) {
                            spec_list.add(item);
                            require += item.book_title + ",";
                        }
                    }

                    if (!require.isEmpty())
                        require = require.substring(0, require.length() - 1);
                    spec_value.setText(require);
                    dialog.cancel();
                }
            });

        }
    });

    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_go_location.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());
            String zipCpde = (getTrainStationZip(currentLocation.getLocation()));
            destination_detail.setZipCode(zipCpde);
            destination_detail.setCountryName("Taiwan");
            destination_detail.setLocality(currentLocation.getStreetAddress());
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    });

    spinner_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));
            String zipCode = (getTrainStationZip(currentLocation.getLocation()));
            departure_detail.setZipCode(zipCode);
            departure_detail.setCountryName("Taiwan");
            departure_detail.setLocality(currentLocation.getStreetAddress());
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    });
}

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();/* w w w. j a v  a  2 s.c o  m*/
}