I've got a simple question. I run this sub several times, and I want to get if there's already a panel at the location of the new panel (to avoid adding a new panel).
B4X:
Dim Left as int = 25dip
Dim Width as int = 15dip
Sub AddPanel(top as int, height as int)
Dim p as panel
'Check here if a panel in Activity is already on the location
Activity.AddView(p,Left,top,Width,height)
End Sub
You have to iterate through all the panels to see it.
Something like
B4X:
Dim PanelFound as Int = 0
For i = 0 To Activity.NumberOfViews - 1
If Activity.GetView(i) Is Panel Then
If Activity.GetView(i).Left = Left AND Activity.GetView(i).Width = Width Then
'Dont add panel
PanelFound = 1
End If
Next
If PanelFound = 0 Then
Activity.AddView(p,Left,top,Width,height)
End If
Thanks, but actually I've to add some details.
I've got like a row of panel (all the panels have same left and width, the only thing different is Height and top).
When I add a panel, I want that if it's covering another panel, the covered panel and the panel to add have width /2.
For example, Google do that in Google Agenda (picture attached).
Sorry if it's not well explained.
Well I woudnt do it with this method then.
I would rather first accumulate the data for that cell, and then decide the layout to show it in depending on the number of events.