B4A Library [Class] CheckList

Informatix

Expert
Licensed User
Longtime User
Any idea how to change the orange color that is describing the press action of items ?
Hope I made myself understood !

I did played with colors found as process variables with no luck.
Thank you
This is not a color in fact but a drawable. By default, the class gets the default drawable for pressed items of your device. You can change that in the class. Search PressedDrawable.
 

marcel

Active Member
Licensed User
Longtime User
Hi,

Would it be possible to have a tree layout? I have items and SubItems I would like to Check. Would this be possible? An Example would be create!
 

marcel

Active Member
Licensed User
Longtime User
Hi,

I have some issues with the class. I need to remove all the items which I do with the following function:

B4X:
Public Sub RemoveAllItems
    Do While NumberOfItems > 0
        RemoveItemAt(0)
    Loop
End Sub

But when I build up the list again I get an error in this function:
B4X:
Private Sub GetParentPanel(MyView As View) As View
    Dim r As Reflector
    Dim v, Parent As View
    r.Target = MyView
    v = r.Target
    Parent = r.RunMethod("getParent")
    Do While Parent <> sv.Panel
        r.Target = Parent
        v = r.Target
        Parent = r.RunMethod("getParent")
    Loop
    Return v
End Sub

this is the exception log:
B4X:
Did you forget to call Activity.LoadLayout?
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:49)
    at com.yazula.android.clschecklist._getparentpanel(clschecklist.java:1937)
    at com.yazula.android.clschecklist._findpanelcontaining(clschecklist.java:102)
    at com.yazula.android.clscategory._customchbx_checkedchange(clscategory.java:249)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at anywheresoftware.b4a.objects.CompoundButtonWrapper$1.onCheckedChanged(CompoundButtonWrapper.java:44)
    at android.widget.CompoundButton.setChecked(CompoundButton.java:137)
    at anywheresoftware.b4a.objects.CompoundButtonWrapper.setChecked(CompoundButtonWrapper.java:55)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:305)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at anywheresoftware.b4a.BA$2.run(BA.java:285)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4921)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
    at dalvik.system.NativeStart.main(Native Method)

Some how it removes a view that is not initialized again with building op the list again. This is my function that refreshes the layout:

B4X:
Public Sub RefreshLayout
 
  lst.RemoveAllItems
 
  Dim l As List
  l=Helpers.SelectCategories(Main.db)

  For Each item As Category In l
          Dim pnl As Panel, lbl As Label, cbx As CheckBox, tBtn As ToggleButton, w As Int
        pnl.Initialize("")
        lbl.Initialize("")
        cbx.Initialize("customChBx")
        cbx.Tag=item.id
        cbx.checked=item.Selected
        lbl.Text = item.Name
        lbl.TextSize = 13
        lbl.TextColor = Colors.DarkGray
        lbl.Gravity = Gravity.CENTER_VERTICAL
       
        Dim checked, unchecked As ColorDrawable
       
        checked.Initialize(Colors.LightGray,0dip)
        unchecked.Initialize(Colors.LightGray, 0dip)
       
        tBtn.Initialize("customTBtn")
        tBtn.TextOff="Overal"
        tBtn.TextOn="Favorite"
        tBtn.TextColor=Colors.RGB(236,106,30)
        tBtn.Tag=item.id
        tBtn.checked = item.Local
       
        Dim sld As StateListDrawable
        sld.Initialize
        sld.AddState(sld.State_Checked, checked)
        sld.AddState(sld.State_Unchecked, unchecked)

        tBtn.Background = sld

        pnl.AddView(cbx,0,0,40dip,40dip)
        w = lst.getWidth - 90dip
        pnl.AddView(lbl,45dip, 0, w, 40dip)   
        w = w + 10dip
        pnl.AddView(tBtn, w, 0, 80dip, 38dip)
        lst.AddCustomItem(item.id, pnl, 40dip)
  Next
  lst.ResizePanel
End Sub
 
Last edited:

PABLO2013

Well-Known Member
Licensed User
Longtime User
GREETINGS THANK YOU,
I have the following problem:

Sub CreateItem(h, i As Int) As Panel
.......

Dim pnl As Panel, lbl As Label, chk As CheckBox, edt As EditText, sb As StartPointSeekBar
pnl.Initialize("")
..........
sb.Initialize("sb") 'View #1
sb.TheBackgroundColor = Colors.Cyan
sb.TheRangeColor = 0xFF33B5E5
sb.MinValue = -9 'Keep the order of this 3 lines of code
sb.maxValue = 9
sb.ThumbValue = 1
sb.SetColorAnimated(300,2323,343345)
pnl.AddView(sb, 150, 15, 250dip, 50dip)
.....
Return pnl
End Sub

Sub sb_value_changed

Dim Checked As Boolean
Checked=False
Dim pnl As Panel
pnl = lst.FindPanelContaining(Sender) i can not find panel containing
...........

End Sub


One error occurs in the module: CheckList v2.22
could you tell me this because doing wrong
Thank you
 

Attachments

  • error.PNG
    86.9 KB · Views: 195

Informatix

Expert
Licensed User
Longtime User
A view is expected by the function but the sender object is not. Please see this problem with the library author because I have no idea of what is a "StartPointSeekBar".
 

Dave O

Well-Known Member
Licensed User
Longtime User
I'm using a checklist with a long click to activate drag and drop.

However, each item (panel) contains several labels, and if the user happens to press the label, the drag-and-drop is not started (presumably because the label itself is getting the long click, not the panel beneath it).

Ideally I would like the entire item to accept a long click to drag-and-drop. Is there a way to "pass through" the long click from the label to the panel? (I tried setting up a long-click event for the label, and using it to trigger the drag-and-drop (by calling the item's StartDragAndDrop sub, or by calling the item's LongClick sub itself), but neither worked.)

I could also just replace the Checklist class with a ULV, but I'm wondering if I'll still have the same issue? (In the end, I may just switch to ULV and use an on-touch button for drag-and-drop instead.)

Thanks!
 

Dave O

Well-Known Member
Licensed User
Longtime User
Yes, that was the problem. I had added click events to the labels, and that interfered with the long click. Fixed and working well again. Thanks!
 

PABLO2013

Well-Known Member
Licensed User
Longtime User
Greetings,
I've been reviewing your project and I feel very good ,
I only know how i can change the characteristics of a label view that does not necessarily have the focus.
Example: if I put a number between 1 and 9 in a text view ( example (5) ) and have 9 items (with more views), put the blue the text on a label to the item 5 ... , thanks
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…