ABMaterial recognizes your device on your phone, tablet or PC.
However, depending on the recognized device, I would like to make some code change. How to do it ?
B4X:
If phone then
// code for phone
End if
If tablet then
// code for tablet
End if
If PC then
// code for PC
End If
ABMaterial recognizes your device on your phone, tablet or PC.
However, depending on the recognized device, I would like to make some code change. How to do it ?
B4X:
If phone then
// code for phone
End if
If tablet then
// code for tablet
End if
If PC then
// code for PC
End If
If small screen - use a small floating button... otherwise - use a regular flat button
B4X:
Dim scwdt As Int = ABMShared.GetDeviceWidth(page)
Dim btncom As ABMButton
If scwdt > -1 And scwdt < 601 Then
btncom.InitializeFloating(page, "cm"&cnum, "mdi-action-note-add", "amber1")
Else
btncom.InitializeFlat(page, "cm"&cnum, "mdi-action-note-add", ABM.ICONALIGN_LEFT ,"Comment", "amber1")
End If
Using GetBrowserWidthHeight (put in ABMShared...)
B4X:
Public Sub GetDeviceWidth( page As ABMPage ) As Int
Dim NowWH As String = ABM.GetBrowserWidthHeight(page)
If NowWH <> "" And NowWH <> ";" Then ' check if we got something useful back
Dim split() As String = Regex.Split(";", NowWH) ' split the string
Dim NewH As Int = split(0)
Else
Dim NewH As Int = -1
End If
Return NewH
End Sub