Android Question Tags with checkboxes and edittexts (SOLVED)

edm68

Member
Licensed User
Longtime User
Hi,
I have a panel with multiple checkboxes and edittexts. Each chkbox has a tag that corresponds with a matching edittext. When I check or uncheck the chkbox I would like for the matching edittext to be enabled or disabled. That part I seem to have figured out (with help of the forum). :)
I would also like for the matching edittext text to be cleared when the chkbox is unchecked and the edittext is disabled. That's where I'm having problems.

B4X:
Sub chkExpPU_CheckedChange(Checked As Boolean)
    Dim chkPU As CheckBox=Sender
    Log(chkPU.Tag)
    For Each v As View In pnlPU.GetAllViewsRecursive
'        Dim edt As EditText        'if I uncomment this I get "variable 'edt' was not initialized"
'        edt.Initialize(edt)        'so I added this & get "variable converted to string" error
        If v Is EditText And v.Tag=chkPU.Tag Then
            If chkPU.Checked Then
                v.Enabled=True
'                edt.Enabled=True    'so I commented this out
            Else
'                edt.Text=""            'so I commented this out
'                edt.Enabled=False    'so I commented this out
                v.Enabled=False
            End If
        End If
    Next
End Sub

Thanks in advance
 

inakigarm

Well-Known Member
Licensed User
Longtime User
If the number of check and edittext are the same I should do it like that: Create an array of checkboxes (that shares the checkedchange event) and editboxes (sharing the events) and control which is the selected checkbox reading the tag (previously you'd to add the index for each checkbox/edittext)
Then you can control diferent checkbox entries (edittext) in a Select Case
 
Upvote 0
Top