B4J Question Event not executing on listview click

Nokia

Active Member
Licensed User
Longtime User
I am trying to allow the user to delete emails from a List View, but when they click the imageview the event does not fire. any ideas?

B4X:
Sub LoadEmailList
    Dim su As StringUtils
    EmailList = su.LoadCSV(Main.WrkFld, csvName, csvChar)
    Dim SortedList As List
    SortedList.Initialize
        
    For Each Row() As String In EmailList
     For Each Col As String In Row
        Dim s As String = SharedMod.DecToString(Col)
        If s <> "" Then
            SortedList.Add(s)
        End If
     Next
    Next
    
    SortedList.Sort(True)
    For i = 0 To SortedList.Size - 1
        
        lvEmailTo.Items.Add(GetEmailToPane(SortedList.Get(i), SortedList.Get(i), "cancel_48.png"))
        
    Next
    
End Sub

Sub GetEmailToPane(Tag As String, Label As String, ImageName As String) As Object
    
    Dim lbl As Label
    lbl.Initialize("lblNode")
    lbl.Text = Label
    lbl.Tag = Tag
    lbl.Font = fx.CreateFont("System", 14, False, False)
    lbl.TextColor = fx.Colors.Black
                        
    Dim IV1 As ImageView
    IV1.Initialize("IVNode")
    IV1.Tag = Tag
    Dim Img As Image = fx.LoadImage(File.DirAssets,ImageName)
    IV1.SetImage(Img)
                        
    Dim AP As AnchorPane
    AP.Initialize("")
    AP.Tag = Tag
    AP.AddNode(IV1,0,0,25,25)
    AP.AddNode(lbl, 30,1.5,300, 15)
    
    Return AP
    
End Sub

Sub lblNode_Click (EventData As MouseEvent)
    Log("lbl clicked")
    
End Sub

Sub IVNode_Click (EventData As MouseEvent)
    Log("x clicked for deleting")
    
End Sub
 

stevel05

Expert
Licensed User
Longtime User
ImageView probably doesn't generate a _Click Event, try using _MouseClicked (EventData As MouseEvent) instead.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
this doesn't exactly address your problem, but it might be relevant.
 

Attachments

  • erel.png
    erel.png
    14.9 KB · Views: 240
Upvote 0

Nokia

Active Member
Licensed User
Longtime User
I've notice if I remote this statement lvEmailTo.Visible = False from code below that the event will fire..


B4X:
Sub lvEmailTo_SelectedIndexChanged(Index As Int)
            
    Dim P As Pane
    p = lvEmailTo.Items.Get(Index)
    If P.Tag <> "" Then
        txtEMTo.Text = txtEMTo.Text & " " & P.Tag & ";"
    End If
        
    lvEmailTo.Visible = False
    
End Sub
 
Upvote 0
Top