Java Question CalendarView's CalendarLayout java.lang.NullPointerException

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Hello friends,

I am writing a wrapper for this project https://github.com/huanghaibin-dev/CalendarView but CalendarLayout is not working ( nothing is shown and when clicking I get java.lang.NullPointerException: Attempt to read from field 'boolean com.haibin.calendarview.CalendarViewDelegate.isShowYearSelectedLayout' on a null object reference

CalendarView seems to work but the problem is with CalendarLayout


My sample

B4X:
#Region  Project Attributes
    #ApplicationLabel: calendarview Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False

    #AdditionalRes : ..\res
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
'    #Extends: android.support.v7.app.AppCompatActivity
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim cal As CalendarLayout
    Dim p As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Log(DateTime.Time(DateTime.Now))
    p.Initialize("")
    
    Activity.AddView(p,0,0,100%x,100%x)

    cal.Initialize("cal",Null)

    Activity.AddView(cal,0,0,100%x,50%x)

End Sub

Sub Activity_Resume

End Sub
Sub activity_click

    Log(cal.isExpand)
    If cal.isExpand Then
        cal.shrink
    Else
        cal.expand
    End If
    
    
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub cal_oncalendarselect(ca As Calendar,isClick As Boolean)
    Log("cal_oncalendarselect"&isClick)
End Sub
Sub cal_oncalendaroutofrange(ca As Calendar)
    Log("cal_oncalendaroutofrange")
End Sub


Sub cal_oncalendarlongclickoutofrange(ca As Calendar)
    Log("cal_oncalendarlongclickoutofrange")
End Sub
Sub cal_oncalendarlongclick(ca As Calendar)
    Log("cal_oncalendarlongclick"&ca.Lunar)
    '    lay.expand
End Sub
Sub cal_onyearchange(year As Int)
    Log("cal_onyearchange"& year)
End Sub
Sub cal_onmonthchange(year As Int,month As Int)
    Log("cal_onmonthchange"& year &"//" & month)
End Sub

Sub cal_onviewchange(isMonthView As Boolean)
    Log("cal_onviewchange"& isMonthView)
End Sub

Sub cal_onweekchange(weekCalendars As List)
    Log("cal_onweekchange"& weekCalendars)
End Sub

Sub cal_oncalendarintercept(ca As Calendar)
    Log("cal_oncalendarintercept")
End Sub

Sub cal_oncalendarinterceptclick(ca As Calendar,isClick As Boolean)
    Log("cal_oncalendarinterceptclick")
End Sub


Source : https://drive.google.com/file/d/1e9eCSShUou2Zph7IzPiy4rumCwISney5/view?usp=sharing
 
Top