Android date Selector

Source: Internet
Author: User

Android date Selector

 

:

 

Open-source projects are developed using Studio. If you use Eclipse to manually import them, you can use the following common methods:

 

public static SimpleDateFormat formatter = new SimpleDateFormat(dd MMM yyyy);             
   Button showDialogButton = (Button) findViewById(R.id.show_dialog_button);showDialogButton.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// Setup caldroid to use as dialogdialogCaldroidFragment = new CaldroidFragment();dialogCaldroidFragment.setCaldroidListener(getListener());Bundle state = savedInstanceState;final String dialogTag = CALDROID_DIALOG_FRAGMENT;if (state != null) {dialogCaldroidFragment.restoreDialogStatesFromKey(getSupportFragmentManager(), state,DIALOG_CALDROID_SAVED_STATE, dialogTag);Bundle args = dialogCaldroidFragment.getArguments();if (args == null) {args = new Bundle();dialogCaldroidFragment.setArguments(args);}} else {// Setup argumentsBundle bundle = new Bundle();// Setup dialogTitledialogCaldroidFragment.setArguments(bundle);}dialogCaldroidFragment.show(getSupportFragmentManager(),CALDROID_DIALOG_FRAGMENT);}});
protected CaldroidListener getListener() { // TODO Auto-generated method stub  return new CaldroidListener() {    @Override     public void onSelectDate(Date date, View view) {     // TODO Auto-generated method stub     dialogCaldroidFragment.dismiss();     Toast.makeText(getApplicationContext(), formatter.format(date),Toast.LENGTH_SHORT).show();};}

Very useful !! This project uses a third-party jar: date4j. If Eclipse integration needs to be downloaded

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.