I am using https://github.com/prolificinteractive/material-calendarview
Right now it is changing the month on the click of Right or Left arrow
How can i change the year directly instead of changing month.
Is this possible android default Calendar View.
Below is my code for prolificinteractive - calendar
public class ActivityCalendar extends AppCompatActivity implements OnDateSelectedListener, OnMonthChangedListener {
private static final DateFormat FORMATTER = SimpleDateFormat.getDateInstance();
private MaterialCalendarView widget;
private String zodiacSign = "";
private HashMap<String,Integer> hashMapMonth = new HashMap<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_calendar);
widget = (MaterialCalendarView)findViewById(R.id.calendarView);
widget.setOnDateChangedListener(this);
widget.setOnMonthChangedListener(this);
}
@Override
public void onDateSelected(@NonNull MaterialCalendarView widget, @Nullable CalendarDay date, boolean selected) {
String strDate = getSelectedDatesString();
Intent returnIntent = new Intent();
returnIntent.putExtra(TagClass.BIRTH_DATE, strDate);
setResult(Activity.RESULT_OK, returnIntent);
finish();
}
@Override
public void onMonthChanged(MaterialCalendarView widget, CalendarDay date) {
//noinspection ConstantConditions
}
private String getSelectedDatesString() {
CalendarDay date = widget.getSelectedDate();
if (date == null) {
return "No Selection";
}
return FORMATTER.format(date.getDate());
}
}
Layout.XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ActivityCalendar">
<com.prolificinteractive.materialcalendarview.MaterialCalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
That doesn't seem to be possible with that library as it is right now.
In order order to do it, you would need to download the sources from github, and add it to your project as a library module.
Then, I would expect changes to be needed in at least these components:
ViewPager.OnPageChangeListener
Also, my impression is that doing these changes would also cause a mayor refactor in the library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With