android.widget.CalendarView Java Examples

The following examples show how to use android.widget.CalendarView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InsertFragment.java    From android-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    database=new DataBase(this.getContext());
    cal_doj=getActivity().findViewById(R.id.calview_doj);
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    data_date = sdf.format(new Date(cal_doj.getDate()));
    cal_doj.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
        @Override
        public void onSelectedDayChange(@NonNull CalendarView calendarView, int year, int month, int date) {
            if(month==12)
                month=1;
            else
                month=month+1;
            data_date=date + "/" + month + "/" + year;
            Toast.makeText(getContext(), date + "/" + month + "/" + year , Toast.LENGTH_SHORT).show();
        }

    });
}
 
Example #2
Source File: MainActivity.java    From privacy-friendly-food-tracker with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    calendarView = (CalendarView) findViewById(R.id.CalendarView); // get the reference of CalendarView
    calendarView.setDate(System.currentTimeMillis(), false, true);
    calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
        @Override
        public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
            Intent intent = new Intent(MainActivity.this, OverviewActivity.class);
            // Build string from chosen date to parse into Date object
            // (month+1) because months count from 0 in java but SimpleDateFormat parses it as 1-12
            String chosenDate = dayOfMonth + "/" + (month+1) + "/" + year;
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            try{
                Date date = sdf.parse(chosenDate);
                long millis = date.getTime();
                intent.putExtra("DATE", millis);
            } catch (ParseException e){
                e.printStackTrace();
            }

            startActivity(intent);
        }
    });
    overridePendingTransition(0, 0);
}
 
Example #3
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult calendarView() {
  return BaseDSL.v(CalendarView.class);
}
 
Example #4
Source File: CalendarViewAssert.java    From assertj-android with Apache License 2.0 4 votes vote down vote up
public CalendarViewAssert(CalendarView actual) {
  super(actual, CalendarViewAssert.class);
}
 
Example #5
Source File: OldCalendarViewActivity.java    From material-calendarview with MIT License 4 votes vote down vote up
@Override
public void onSelectedDayChange(
    CalendarView view, int year, int month,
    int dayOfMonth) {
  textView.setText(FORMATTER.format(view.getDate()));
}
 
Example #6
Source File: CalendarLayout.java    From anvil-examples with MIT License 4 votes vote down vote up
public void onDateChanged(CalendarView v, int y, int m, int d) {
    dateInMillis = new GregorianCalendar(y, m, d).getTimeInMillis();
}
 
Example #7
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void onDateChange(CalendarView.OnDateChangeListener arg) {
  return BaseDSL.attr("onDateChange", arg);
}
 
Example #8
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void calendarView(Anvil.Renderable r) {
  return BaseDSL.v(CalendarView.class, r);
}
 
Example #9
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult calendarView() {
  return BaseDSL.v(CalendarView.class);
}
 
Example #10
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void onDateChange(CalendarView.OnDateChangeListener arg) {
  return BaseDSL.attr("onDateChange", arg);
}
 
Example #11
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void calendarView(Anvil.Renderable r) {
  return BaseDSL.v(CalendarView.class, r);
}
 
Example #12
Source File: OldCalendarViewActivity.java    From material-hijri-calendarview with Apache License 2.0 4 votes vote down vote up
@Override
public void onSelectedDayChange(CalendarView view, int year, int month,
                                int dayOfMonth) {
    textView.setText(FORMATTER.format(view.getDate()));
}
 
Example #13
Source File: DatePicker.java    From ticdesign with Apache License 2.0 4 votes vote down vote up
@Override
public CalendarView getCalendarView() {
    return mCalendarView;
}
 
Example #14
Source File: DateView.java    From always-on-amoled with GNU General Public License v3.0 4 votes vote down vote up
public CalendarView getCalendarView() {
    return calendarView;
}
 
Example #15
Source File: OldCalendarViewActivity.java    From calendarview2 with MIT License 4 votes vote down vote up
@Override
public void onSelectedDayChange(CalendarView view, int year, int month,
                                int dayOfMonth) {
    textView.setText(FORMATTER.format(view.getDate()));
}
 
Example #16
Source File: DatePicker.java    From ticdesign with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the {@link CalendarView}.
 * <p>
 * This method returns {@code null} when the
 * {@link android.R.attr#datePickerMode} attribute is set
 * to {@code calendar}.
 *
 * @return The calendar view.
 * @see #getCalendarViewShown()
 */
public CalendarView getCalendarView() {
    return mDelegate.getCalendarView();
}
 
Example #17
Source File: DatePicker.java    From ticdesign with Apache License 2.0 votes vote down vote up
CalendarView getCalendarView();