HI, All
For any new visual view in B4A I prefer to have the source code class, so trying to study how to correctly create view classes.
Now i'm trying to change CLVSwipe class. I see that it's recommended to use only the latest B4X objects and so on...
But for a view creation in a class - i prefer not to have the inteface layout file, if the interface is simple - just 1 or 2 views are required, so - just to create the panel (and 1-2 views) by the class code.
But the panel container must be initialized firstly. Please, help to understand how to initialize the class interface correctly without loading layouts.
Here i need to add the progressbar into p2 panel, that is added on to the Base panel, but p2 is not initialized.
Or XUI crossplatform idea is that all 3 platform must be inited only via layout loading and creating views by code is impossible ?
For any new visual view in B4A I prefer to have the source code class, so trying to study how to correctly create view classes.
Now i'm trying to change CLVSwipe class. I see that it's recommended to use only the latest B4X objects and so on...
But for a view creation in a class - i prefer not to have the inteface layout file, if the interface is simple - just 1 or 2 views are required, so - just to create the panel (and 1-2 views) by the class code.
But the panel container must be initialized firstly. Please, help to understand how to initialize the class interface correctly without loading layouts.
B4X:
'version 0.1
Sub Class_Globals
Private mWV As WebView
Public Base As B4XView
Private TouchXStart, TouchYStart As Float
Private HandlingSwipe As Boolean
Private xui As XUI
Private mCallback As Object
Private mEventName As String
Private mPullToRefreshPanel As B4XView
Private PullToRefreshSwipe As Boolean 'ignore
Private WaitingForRefreshToComplete As Boolean
Private mActivity As Activity
Private ProgressBar1 As B4XView
End Sub
Public Sub Initialize (Activity As Activity, cWV As WebView, Callback As Object, EventName As String)
mActivity = Activity
Dim creator As TouchPanelCreator
Base = creator.CreateTouchPanel("TouchPanel")
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, 1dip, 1dip)
mWV = cWV
Dim p1 As B4XView = mWV.Parent
p1.AddView(Base, mWV.Left, mWV.Top, mWV.Width, mWV.Height)
mWV.RemoveView
Base.AddView(mWV, 0, 0, Base.Width, Base.Height)
mCallback = Callback
mEventName = EventName
Dim p2 As B4XView = xui.CreatePanel("")
p2.SetLayoutAnimated(0, 0, 0, 100%x, 70dip)
p1.AddView
setPullToRefreshPanel(p2)
mPullToRefreshPanel.AddView(ProgressBar1, 0, 0, 50dip, 50dip)
End Sub
Private Sub setPullToRefreshPanel(pnl As B4XView)
If pnl.Parent.IsInitialized Then pnl.RemoveViewFromParent
If mPullToRefreshPanel.IsInitialized Then mPullToRefreshPanel.RemoveViewFromParent
mPullToRefreshPanel = pnl
Base.AddView(mPullToRefreshPanel, 0, 0, Base.Width, mPullToRefreshPanel.Height)
mPullToRefreshPanel.SendToBack
mPullToRefreshPanel.Visible = False
End Sub
Here i need to add the progressbar into p2 panel, that is added on to the Base panel, but p2 is not initialized.
Or XUI crossplatform idea is that all 3 platform must be inited only via layout loading and creating views by code is impossible ?
Last edited: