Android Question Problem with Droppy library with labels

Discussion in 'Android Questions' started by RB Smissaert, Aug 18, 2019.

  1. RB Smissaert

    RB Smissaert Well-Known Member Licensed 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
     

    Attached Files:

  2. DonManfred

    DonManfred Expert Licensed User

    as far as i can see all are working in your example.
     
  3. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    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
     
  4. DonManfred

    DonManfred Expert Licensed 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

    Code:
    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(0Is Label Then
                    
    Dim lbl As Label = item.getChildAt(0)
                    
    Log(lbl.Text)
                
    End If
            
    else if item.ChildCount = 2 Then
                
    If item.getChildAt(1Is 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
     
  5. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    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
     
  6. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

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

    RBS
     

    Attached Files:

  7. DonManfred

    DonManfred Expert Licensed User

    What EXACTLY is the problem?
     
  8. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    The problem that menu items (labels) are not responding to clicks as explained in the first post of this thread.
    Does this problem not show in the last uploaded .zip file?

    RBS
     
  9. DonManfred

    DonManfred Expert Licensed User

    Which one?
    The Test1 did responds if you add a click event for this item
    Code:
    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
     
    RB Smissaert and Erel like this.
  10. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

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

    RBS
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice