Can you upload a small example?
Public Sub Clear1
For x = 0 To panels.Size -1
Dim removePanel As Panel
removePanel = panels.Get(x)
removePanel.RemoveView
Next
items.Clear
panels.Clear
sv.Panel.Height = 0
sv.Invalidate
End Sub
clv1.Add(pnlStatus, pnlStatus.Height + 50%y, "Item 4")
Hi,
I think this custom scrollview is great but I have a question. I have layout with 4 views and one of them is a checkbox.
In your sample you do something like this:
Dim lbl As Label
Dim chk As CheckBox
lbl = pnl.GetView(0)
chk = pnl.GetView(2)
lbl.Text = "Clicked!"
Msgbox("Item value: " & clv1.GetValue(itemIndex) & CRLF & "Check value: " & chk.Checked, "")
How do I know which index a view has in a layout? I want to get to my checkbox value but i'm not sure which index the view has.
Cheers.
Interesting but not really what I'm looking for in this specific case. I just need to know how I can get an Index of a view. The getView method needs to have a view Index.
I wish I knew thatLong time ago that i added these. Wouldn't it be great to add the Index to the properties in the designer? So if you click on a view that it shows the Index.
'Updates a custom item at the specified index.
Public Sub UpdateAt(Index As Int, Pnl As Panel, ItemHeight As Int, Value As Object)
Dim removePanel, p As Panel
removePanel = panels.Get(Index)
items.RemoveAt(Index)
panels.RemoveAt(Index)
removePanel.RemoveView
Dim sd As StateListDrawable
sd.Initialize
sd.AddState(sd.State_Pressed, pressedDrawable)
sd.AddCatchAllState(Pnl.Background)
'create another panel to handle the click event
Dim p As Panel
p.Initialize("panel")
p.Background = sd
Dim cd As ColorDrawable
cd.Initialize(Colors.Transparent, 0)
Pnl.Background = cd
p.AddView(Pnl, 0, 0, sv.Width, ItemHeight)
p.Tag = Index
Dim top As Int
If Index = 0 Then
top = dividerHeight
Else
Dim previousPanel As Panel
previousPanel = panels.Get(Index - 1)
top = previousPanel.top + previousPanel.Height + dividerHeight
End If
items.InsertAt(Index, Value)
panels.InsertAt(Index, p)
sv.Panel.AddView(p, 0, top, sv.Width, ItemHeight)
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?