Android Question ACCheckBox type in AppCompat Library

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Hi,
i have been developing a custom list view which contains child panels. Each panel contains a number of views, one of which is a Checkbox.

When the user clicks on the item. I use the following code to highlight the check box.

B4X:
Sub clvCurrentOrder_ItemClick (Index As Int, Value As Object)
    Private pnl As Panel = clvCurrentOrder.GetPanel(Index)
    Private vw As View
    Private chk As CheckBox
    Private i As Int
   
    For i = 0 To pnl.NumberOfViews -1
        vw = pnl.GetView(i)
        If vw Is CheckBox Then
            chk = vw
            If chk.Checked Then
                chk.Checked = False
            Else
                chk.Checked = True
            End If
        End If
    Next

End Sub

This works great.

I then changed my application to the AppCompat theme and changed the Checkbox to a ACCheckBox type.

I changed the If statement to what I thought it should be:

B4X:
        If vw Is ACCheckBox Then

However, the checkbox is never checked.

A look with the debugger shows that the checkbox is actually a "BALayout" type.

Does anyone know why this is?

Thanks

Andrew
 

Chris Lee

Member
Licensed User
Hi, came across your unanswered post which I realise is a month old. Hopefully you worked it out already. I had the same problem. Suggestion was to use a recursive search. It seems that ACCheckbox gets buried in the BALayout. The example below probably doesn't fit your needs exactly but should help you along the right path. For speed I'd try checking for the BALayout type then running the recursive search on that view.

For Each v In Pnl.GetAllViewsRecursive
If v Is ACCheckBox Then
Dim Mychk As ACCheckBox = v
' do something with Mychk
End If
Next
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
i did see the code somewhere... :D

@Chris Lee you should use code tags when posting code
 
Upvote 0
Top