List of usage examples for android.widget CalendarView setOnDateChangeListener
public void setOnDateChangeListener(OnDateChangeListener listener)
From source file:org.hancel.customclass.PickCalendar.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pick_calendar); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setTitle("Pick Date"); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View actionBarButtons = inflater.inflate(R.layout.edit_event_custom_actionbar, new LinearLayout(this), false);// www. j a va2 s. c om View cancelActionView = actionBarButtons.findViewById(R.id.action_cancel); cancelActionView.setOnClickListener(mActionBarListener); View doneActionView = actionBarButtons.findViewById(R.id.action_done); doneActionView.setOnClickListener(mActionBarListener); getActionBar().setHomeButtonEnabled(false); getActionBar().setDisplayShowHomeEnabled(false); getActionBar().setDisplayHomeAsUpEnabled(false); getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowCustomEnabled(true); getActionBar().setCustomView(actionBarButtons); CalendarView calendar = (CalendarView) findViewById(R.id.calendarWeight); calendar.setOnDateChangeListener(new CalendarView.OnDateChangeListener() { @Override public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) { currentDate.set(year, month, dayOfMonth); } }); }