Android Question Problem with Droppy library with labels

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Posted this is a different thread:
https://www.b4x.com/android/forum/threads/droppy-library.108691/
but the problem in that thread (lost button click event) has been solved, but got a different problem now
and that is that if I use labels for the menu items (which seems to be needed to specify the height of the items) some menu items don't respond to clicking the menu item.

Attached a project that demonstrates this.
I hope this can be solved as the Droppy library seems very good as it allows menu item icons, separators and I think also sub menu's.

RBS
 

Attachments

  • DroppyExToolbar.zip
    10.4 KB · Views: 230

DonManfred

Expert
Licensed User
Longtime User
some menu items don't respond to clicking the menu item
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Droppy_onClicked(com.shehabic.droppy.views.DroppyMenuItemView{3d6c3d4 VFE...C.. ......ID 0,280-505,448 #1}, 1)
2
Droppy_onClicked(com.shehabic.droppy.views.DroppyMenuItemView{aa7fbe6 VFE...C.. ......ID 0,0-505,168 #0}, 0)
1
Test1
Droppy_onClicked(com.shehabic.droppy.views.DroppyMenuItemView{c14297d VFE...C.. ......ID 0,448-505,616 #2}, 2)
1
Options
Droppy_onClicked(com.shehabic.droppy.views.DroppyMenuItemView{4304cc3 VFE...C.. ......ID 0,618-505,786 #3}, 3)
1
Options1a
Droppy_onClicked(com.shehabic.droppy.views.DroppyMenuItemView{1c64940 VFE...C.. ......ID 0,786-505,954 #4}, 4)
1
Options1b
as far as i can see all are working in your example.
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
as far as i can see all are working in your example.

I downloaded the project I uploaded, added the resource folder and changed the targetSdkVersion to 26 (just as in the
project that had the problem), compiled and indeed it runs all fine.
No idea what what the difference is with the old project.
In any case, thanks for letting me know what you found.

RBS
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
compiled and indeed it runs all fine
the label is not recognized in the item with the image.
and the checkbox has a missing checkedchange event

replace your code (Droppy_onClicked) with this

B4X:
Sub Droppy_onClicked(view As Object, index As Int)
    Log($"Droppy_onClicked(${view}, ${index})"$)
    If view Is Button Then
        Log("btn")
    else if view Is Label Then
        Log("lbl")
    else if view Is CheckBox Then
        Log("chk")
    else if view Is DroppyMenuItemView Then
        Dim item As DroppyMenuItemView = view
        Log(item.ChildCount)
        If item.ChildCount = 1 Then
            If item.getChildAt(0) Is Label Then
                Dim lbl As Label = item.getChildAt(0)
                Log(lbl.Text)
            End If
        else if item.ChildCount = 2 Then
            If item.getChildAt(1) Is Label Then
                Dim lbl As Label = item.getChildAt(1)
                Log(lbl.Text)
            End If
            
        End If
    End If
End Sub
Sub cb_CheckedChange(Checked As Boolean)
    Dim chk As CheckBox = Sender
    Log($"CheckedChange(${Checked},${chk.Text})"$)
End Sub
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
the label is not recognized in the item with the image.
and the checkbox has a missing checkedchange event

replace your code (Droppy_onClicked) with this

B4X:
Sub Droppy_onClicked(view As Object, index As Int)
    Log($"Droppy_onClicked(${view}, ${index})"$)
    If view Is Button Then
        Log("btn")
    else if view Is Label Then
        Log("lbl")
    else if view Is CheckBox Then
        Log("chk")
    else if view Is DroppyMenuItemView Then
        Dim item As DroppyMenuItemView = view
        Log(item.ChildCount)
        If item.ChildCount = 1 Then
            If item.getChildAt(0) Is Label Then
                Dim lbl As Label = item.getChildAt(0)
                Log(lbl.Text)
            End If
        else if item.ChildCount = 2 Then
            If item.getChildAt(1) Is Label Then
                Dim lbl As Label = item.getChildAt(1)
                Log(lbl.Text)
            End If
           
        End If
    End If
End Sub
Sub cb_CheckedChange(Checked As Boolean)
    Dim chk As CheckBox = Sender
    Log($"CheckedChange(${Checked},${chk.Text})"$)
End Sub

Not sure what is going on, but the code in Main of the project I downloaded from my uploaded zipped project is not as in the project I uploaded.
There is no Sub AddDroppy, which configures the droppy menu. Strangely though, it shows all the labels and all working fine.
Adding your posted Sub Droppy_onClicked and Sub cb_CheckedChange to my old project doesn't solve the problem with the labels.
I tried cleaning the old project but no difference.
I think it has to do with the fact that both b4a files (AppCompat.b4a) have the same name.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
the label is not recognized in the item with the image.
and the checkbox has a missing checkedchange event

replace your code (Droppy_onClicked) with this

B4X:
Sub Droppy_onClicked(view As Object, index As Int)
    Log($"Droppy_onClicked(${view}, ${index})"$)
    If view Is Button Then
        Log("btn")
    else if view Is Label Then
        Log("lbl")
    else if view Is CheckBox Then
        Log("chk")
    else if view Is DroppyMenuItemView Then
        Dim item As DroppyMenuItemView = view
        Log(item.ChildCount)
        If item.ChildCount = 1 Then
            If item.getChildAt(0) Is Label Then
                Dim lbl As Label = item.getChildAt(0)
                Log(lbl.Text)
            End If
        else if item.ChildCount = 2 Then
            If item.getChildAt(1) Is Label Then
                Dim lbl As Label = item.getChildAt(1)
                Log(lbl.Text)
            End If
           
        End If
    End If
End Sub
Sub cb_CheckedChange(Checked As Boolean)
    Dim chk As CheckBox = Sender
    Log($"CheckedChange(${Checked},${chk.Text})"$)
End Sub

Attached the zipped project (zipping the actual project folder, not File, Export as zip), hopefully showing the problem.

RBS
 

Attachments

  • DroppyExToolbar2.zip
    32.4 KB · Views: 226
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
The problem that menu items (labels) are not responding to clicks as explained in the first post of this thread.
Which one?
The Test1 did responds if you add a click event for this item
B4X:
Sub lbl1_Click
    Dim lbl As Label = Sender
    Log($"lbl1_Click(${lbl.Text})"$)
    pop.dismiss(True)
End Sub
Sub lbl2_Click
   Dim lbl As Label = Sender
   Log($"lbl2_Click(${lbl.Text})"$)
   pop.dismiss(True)
End Sub
all others are working
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Which one?
The Test1 did responds if you add a click event for this item
B4X:
Sub lbl1_Click
    Dim lbl As Label = Sender
    Log($"lbl1_Click(${lbl.Text})"$)
    pop.dismiss(True)
End Sub
Sub lbl2_Click
   Dim lbl As Label = Sender
   Log($"lbl2_Click(${lbl.Text})"$)
   pop.dismiss(True)
End Sub
all others are working

Aaah, OK!
I thought wrongly that this was taken care of in Sub Droppy_onClicked.
Thank for rectifying that.

RBS
 
Upvote 0
Top