Open ashik991 opened 3 years ago
Same here. I encounter the same issue: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object java.util.Map.get(java.lang.Object)' on a null object reference at org.naishadhparmar.zcustomcalendar.CustomCalendar$3.onClick(CustomCalendar.java:275)
Any solution for this?
OnNavigationButtonClickedListener use whichbutton you click after that implement desired view that you want
OnNavigationButtonClickedListener use whichbutton you click after that implement desired view that you want
It would be very nice of you if you share this specific code.
@Override public Map<Integer, Object>[] onNavigationButtonClicked(int whichButton, Calendar newMonth) { Map<Integer, Object>[] arr = new Map[2];
if (whichButton==CustomCalendar.NEXT){
// view you want
}if (whichButton==CustomCalendar.PREVIOUS){
// view you want
}
return arr;
}
--> call calendar instance to get the current month and implement on view as per your requirement.
I get this error, "Attempt to invoke interface method 'java.lang.Object java.util.Map.get(java.lang.Object)' on a null object reference at org.naishadhparmar.zcustomcalendar.CustomCalendar$3.onClick(CustomCalendar.java:275)", when I navigate to the next month and click on a date.
I encountered the same issue because i was calling this listener directly without using hashmap or simply i can say without defining properties and setting these to hashmap. I defined one property ("default") ,then this listener worked.
override fun onNavigationButtonClicked( whichButton: Int, newMonth: Calendar? ): Array<MutableMap<Int, Any>?> { val arr = arrayOfNulls<MutableMap<Int, Any>>(2)
val currentMonth: Month = LocalDate.now().month
val currentYear: Int = LocalDate.now().year
if (newMonth != null) {
if (newMonth.get(Calendar.MONTH)+1>currentMonth.value){
customeCalander.setNavigationButtonEnabled(CustomCalendar.PREVIOUS,true)
}else{
if (newMonth.get(Calendar.YEAR)==currentYear)
customeCalander.setNavigationButtonEnabled(CustomCalendar.PREVIOUS,false)
else
customeCalander.setNavigationButtonEnabled(CustomCalendar.PREVIOUS,true)
}
}
when (newMonth?.get(Calendar.MONTH)) {
Calendar.JANUARY -> {
arr[0] = HashMap<Int, Any>().apply {
}
arr[1] = null // Optional: This is the map linking a date to its tag.
}
Calendar.FEBRUARY -> {
arr[0] = HashMap<Int, Any>().apply {
}
arr[1] = null // Optional: This is the map linking a date to its tag.
}
Calendar.MARCH -> {
arr[0] = HashMap<Int, Any>().apply {
}
}
Calendar.APRIL -> {
arr[0] = HashMap<Int, Any>().apply {
}
arr[1] = null // Optional: This is the map linking a date to its tag.
}
Calendar.JULY -> {
arr[0] = HashMap<Int, Any>().apply {
}
arr[1] = null // Optional: This is the map linking a date to its tag.
}
Calendar.AUGUST -> {
arr[0] = HashMap<Int, Any>().apply {
}
arr[1] = null // Optional: This is the map linking a date to its tag.
}
Calendar.JUNE -> {
arr[0] = HashMap<Int, Any>().apply {
}
}
Calendar.MAY -> {
arr[0] = HashMap<Int, Any>().apply {
}
}
Calendar.SEPTEMBER -> {
arr[0] = HashMap<Int, Any>().apply {
}
}
Calendar.OCTOBER -> {
arr[0] = HashMap<Int, Any>().apply {
}
}
Calendar.NOVEMBER -> {
arr[0] = HashMap<Int, Any>().apply {
}
}
Calendar.DECEMBER -> {
arr[0] = HashMap<Int, Any>().apply {
}
}
}
return arr
}
try this code...
I get this error, "Attempt to invoke interface method 'java.lang.Object java.util.Map.get(java.lang.Object)' on a null object reference at org.naishadhparmar.zcustomcalendar.CustomCalendar$3.onClick(CustomCalendar.java:275)", when I navigate to the next month and click on a date.