Android Question xCustomListView - LongClick

LucaMs

Expert
Licensed User
Longtime User
Unlike the ListView (and the many apps), LongClick on a Label inside a xCustomListView is not detected (nor, even less, on other View types).

Furthermore, the behavior is different in b4a and b4j; in b4a only the click event of the label fires, in b4j, after this event, also the LongClick of xCLV starts.

However, apart from the different behavior between the two platforms, the main point is that the LongClick on the Label should happen as in a normal ListView.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
b4j, after this event, also the LongClick of xCLV starts
I guess that you haven't consumed the mouse event. However this is again not the correct place to discuss it as it is a B4J question.

LongClick on a Label inside a xCustomListView is not detected
The handling of touch events in views inside ScrollView (CustomListView = ScrollView) is more sensitive as in many cases the ScrollView intercepts the gesture as a scrolling gesture.

However I just tried it and it works fine here:
B4X:
Sub Globals
   Private xui As XUI
   Private CustomListView1 As CustomListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   For i = 1 To 100
       Dim lbl As Label
       lbl.Initialize("lbl")
       lbl.Text = "AAAA"
       Dim x As B4XView = lbl
       x.SetTextAlignment("CENTER", "CENTER")
       x.TextColor = xui.Color_Black
       Dim p As B4XView = xui.CreatePanel("")
       p.SetLayoutAnimated(0, 0, 0, 100%x, 100dip)
       p.AddView(lbl, 0, 0, 100dip, 100dip)
       CustomListView1.Add(p, "")
   Next
End Sub

Sub lbl_Click
   Log("click")
End Sub

Sub lbl_LongClick
   Log("long")
End Sub

Sub CustomListView1_ItemLongClick (Index As Int, Value As Object)
   Log("CLV Long")
End Sub
 
Upvote 0
Top