Android Question Buttons in b4xlib not available

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I have a b4xlib for a customized date pick picker. Code and files are taken from XUI Views.b4xlib and altered.
All works perfectly fine in release mode, but in debug mode the buttons are not available, so I can't access them.
Attached the b4xlib file.

This is the code in Activity_Create:

B4X:
    'these apply to PickDate.b4xlib, wich holds altered code from XUI Views.b4xlib
    '-----------------------------------------------------------------------------
    DialogB4X_Alt.Initialize(Activity)
    DialogB4X_Alt.TitleBarColor = Colors.RGB(255, 255, 32) 'yellow
    DialogB4X_Alt.TitleBarTextColor = Colors.Black
    DialogB4X_Alt.BlurBackground = False
    DialogB4X_Alt.OverlayColor = Colors.ARGB(0, 255, 255, 255) 'transparent white
    DialogB4X_Alt.iAlterHeight = -40dip '<<<<<<< added as Public variable to B4XDialog_ALT class in PickDate.b4xlib
    
    DateTemplate_Alt.Initialize
    DateTemplate_Alt.MinYear = 1900
    DateTemplate_Alt.MaxYear = 2030
    DateTemplate_Alt.DaysInMonthColor = Colors.Black
    DateTemplate_Alt.DaysInWeekColor = Colors.Blue
    DateTemplate_Alt.SelectedColor = Colors.LightGray
    
    'this will be False in debug mode, but True in release mode (!?)
    '--------------------------------------------------------------------
    Log("DateTemplate_Alt.btnToday.IsInitialized: " & DateTemplate_Alt.btnToday.IsInitialized)

This is the code that shows the date dialog:

B4X:
Sub btnDOBDialog_Click()
    
    DialogB4X_Alt.Title = "Pick a DOB"
    DialogB4X_Alt.BackgroundColor = Colors.RGB(255, 255, 224)

    'No need for Cancel as DateTemplate_Alt has this button and also Today button and YearsFastbutton
    '------------------------------------------------------------------------------------------------
    Wait For (DialogB4X_Alt.ShowTemplate(DateTemplate_Alt, "", "", "")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        lblDOB2.Text = General.Ticks2String(DateTemplate_Alt.Date, "", False)
        lXL_DOB = General.Ticks2ExcelDate(DateTemplate_Alt.Date)
        DateTime.DateFormat = "dd/MMM/yyyy"
        strDOB = DateTime.Date(DateTemplate_Alt.Date)
    End If
    
End Sub

Any idea what I might be doing wrong here?

RBS
 

Attachments

  • PickDate.b4xlib
    16.7 KB · Views: 185

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Does it work with the source code, instead of the b4xlib?
Just tried that and yes that works fine in both release and debug mode.
There is a warning in the log:
Main - 10462: Layout file 'datepicker.bal' is not used. Are you missing a call to Activity.LoadLayout? (warning #16)
But I take it that I can ignore that as all works well.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Ok. Please create a small project that uses this library and reproduces the error and upload it.
I created the minimal project, using that same b4xlib, PickDate.b4xlib and strangely the mentioned problem (buttons not being available) was then also happening in release mode. Then had a look at the file in XUI_Views.b4xlib and see if there might be any files missing from my altered b4xlib. Firstly, I added Dialog.css to the Files folder, but that
made no difference. I then added XUIViewsUtils.bas (along the 2 other .bas files) and that solved the problem both in release and debug mode. Somewhat strange that I had
no warning at compile time or runtime about this file missing. In any case all solved now. Attached the altered b4xlib file.

RBS
 

Attachments

  • PickDate.b4xlib
    18.5 KB · Views: 163
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I created the minimal project, using that same b4xlib, PickDate.b4xlib and strangely the mentioned problem (buttons not being available) was then also happening in release mode. Then had a look at the file in XUI_Views.b4xlib and see if there might be any files missing from my altered b4xlib. Firstly, I added Dialog.css to the Files folder, but that
made no difference. I then added XUIViewsUtils.bas (along the 2 other .bas files) and that solved the problem both in release and debug mode. Somewhat strange that I had
no warning at compile time or runtime about this file missing. In any case all solved now. Attached the altered b4xlib file.

RBS
I got a feeling that the problem was caused by something else. I put the altered b4xlib back in my real app (working fine in both debug and release mode in the tiny demo project) and I had the same problem again, now in both debug and release mode. I think it might be a timing issue as I changed in B4XDateTemplate_ALT.bas in
the Sub Initialize this:
pnlDialogAnimated.SetLayout(0, 0, 0, 320dip, 300dip) to this:
pnlDialog.SetLayout(0, 0, 320dip, 300dip)

I also took XUIViewsUtils.bas out of the b4xlib files and instead set a library reference to XUI_Views in the main project.

Now it works fine both in release and debug mode in the real project and also in the small demo project.
 

Attachments

  • PickDate.b4xlib
    17.1 KB · Views: 161
Upvote 0
Top