Android Question xCustomListView and check box

victormedranop

Well-Known Member
Licensed User
Longtime User
Hi, i'm using xcustomlistview with checkbox and label inside. it's working ok but i havent found the way when i click on one checkbox must uncheck all others.

apreceated your help.

Victor Medrano
 

Attachments

  • 1.PNG
    1.PNG
    8.8 KB · Views: 232

mangojack

Expert
Licensed User
Longtime User
The Checkbox also has a Click event .. which I found easier to handle as the CheckChange event does not fire every time you uncheck other CheckBox 's

Just alter the CheckBox Event signature. ...

B4X:
Sub CheckBox1_Click()
 
    Dim index As Int = clv1.GetItemFromView(Sender)
    Log($" Checkboxx  ${index+1} has been clicked ... "$)

    'uncheck other checkbox /s
    For i = 0 To clv1.Size -1
        If i <> index Then
            Dim p As B4XView = clv1.GetPanel(i)
            Dim chk As B4XView = p.GetView(2)    '@@ assuming checkbox is 3rd view in panel
            chk.Checked = False
        End If
    Next
 
End Sub
 
Last edited:
Upvote 0

victormedranop

Well-Known Member
Licensed User
Longtime User
HI, mangojack

got this error , what you think ?


B4X:
checkbox click
 Checkboxx  4 has been clicked ... 
main_checkbox1_click (java line: 1929)
java.lang.RuntimeException: Object should first be initialized (View).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at anywheresoftware.b4a.objects.B4XViewWrapper.GetView(B4XViewWrapper.java:298)
    at net.nowyouseeme.lottery.loteria._checkbox1_click(loteria.java:1929)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:4438)
    at android.widget.CompoundButton.performClick(CompoundButton.java:100)
    at android.view.View$PerformClick.run(View.java:18439)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5095)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
    at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0
Top