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