Android Question Dialog.ShowTemplate(DateTemplate.... resize?

Tony Tetley

Member
Licensed User
Longtime User
This is working fine for me. I don't find any way to change the size of the calendar (date picker). It is fine on my phone but it would be nice to make it larger on my tablet. Is this possible?

Thanks,
 

toby

Well-Known Member
Licensed User
Longtime User
Check this thread:
 
Upvote 0

Tony Tetley

Member
Licensed User
Longtime User
Toby, thanks for the reply. I understand what was explained in the thread you pointed out. However, I cannot figure out where the templated exist or how to copy and modify it. Any clues?

Thanks,

Tony
 
Upvote 0

toby

Well-Known Member
Licensed User
Longtime User
Add the attached file to your project and open it. I never did such change in the past, therefore I can't change the source code for you and you need to try it yourself. In case you still need further help, then ask again for it from the community.
 

Attachments

  • B4XDateTemplate1.bas
    5.9 KB · Views: 118
Upvote 0

toby

Well-Known Member
Licensed User
Longtime User
You need to change related declaration as follows:
B4X:
Dim dateTemplate as B4XDateTemplate1 'not the default B4XDateTemplate
 
Upvote 0

PaulMeuris

Active Member
Licensed User
You could of course assemble your own calendar date picker using the example from this thread: B4XDialog examples
To adjust the dialog to the screen size you could change the following code:
The calendar dialog:
private Sub show_caldialog
    Dim devwidth As Int = GetDeviceLayoutValues.Width
    Dim devheight As Int = GetDeviceLayoutValues.height - 80dip     ' title bar height not included
    lblseldate.Text = ""
    Dim pnl As B4XView = xui.CreatePanel("")
    pnl.RemoveAllViews
    pnl.SetLayoutAnimated(0dip, 0dip, 0dip, devwidth, devheight-40dip)
    Dim rsub1 As ResumableSub =  caldialog.ShowCustom(pnl, "OK", "", "")
    pnl.AddView(cal.set_date_picker(displaymonth,displayyear),0,0,pnl.Width,devheight-40dip)
    …
And in the calender class:
The month panel:
Public Sub set_month_panel(mnth As Int, yr As Int) As Panel
            … 'after boxheight declaration
    ' screen adjustments
    Dim screensize As Double = GetDeviceLayoutValues.ApproximateScreenSize
    Dim devwidth As Int = GetDeviceLayoutValues.Width/2
    Dim devheight As Int = GetDeviceLayoutValues.height/2 - 80dip     ' title bar height not included
    If screensize > 8 Then
        Dim devwidth As Int = GetDeviceLayoutValues.Width
        Dim devheight As Int = GetDeviceLayoutValues.height - 80dip     ' title bar height not included
    End If
    Private boxwidth As Int = DipToCurrent(devwidth/7)
    Private boxheight As Int = DipToCurrent(devheight/8)        ' devide by 9 for larger screens
    …
The date picker buttons:
Public Sub set_date_picker(intmonth As Int, intyear As Int) As Panel
    Dim devwidth As Int = GetDeviceLayoutValues.Width
    Dim devheight As Int = GetDeviceLayoutValues.height - 40dip     ' title bar height not included
    pnlpicker.Initialize("pnlpicker")
    pnlpicker.RemoveAllViews
    Private btnprev As Button = set_button("PREV",Colors.ARGB(100,182,221,249),"btnprev")
    pnlpicker.AddView(btnprev,0dip,0dip,70dip,40dip)
    lblseldate = set_label("",Colors.ARGB(100,230,230,230),"")
    pnlpicker.AddView(lblseldate,140dip,0dip,devwidth - 210dip,40dip)
    Private btnnext As Button = set_button("NEXT",Colors.ARGB(100,182,221,249),"btnnext")
    pnlpicker.AddView(btnnext,devwidth - 70dip,0dip,70dip,40dip)
    Private pnlmonth As Panel
    pnlmonth.Initialize("pnlmonth")
    pnlmonth = set_month_panel(intmonth,intyear)
    Private btntoday As Button = set_button("NOW",Colors.ARGB(100,182,221,249),"btntoday")
    pnlpicker.AddView(btntoday,70dip,0dip,70dip,40dip)
    pnlpicker.AddView(pnlmonth,0dip,40dip,devwidth,devheight-40dip)
    pnlpicker.SetLayoutAnimated(0dip, 0dip, 0dip, devwidth, devheight-40dip)
    Return pnlpicker
End Sub
no colors or borders:
Private Sub set_background(intcolor As Int) As StateListDrawable
    …
    sd.AddState(sd.State_Enabled,cd)        ' comment out this line for no colors, no borders
    …
The pressed color remains red.
caldialog1.png
caldialog2.png
 
Upvote 0
Top