Android Question DraggableView Click event

dannyjon

Member
Licensed User
Longtime User
I have created draggable view with the following code and works well but I can not handle any click/touch events, only the drag:

Main:
B4X:
Activity.LoadLayout("1")
Dim dv1 As DraggableView
dv1.Initialize(Activity,p2)
p2.SetBackgroundImage(LoadBitmap(File.DirAssets,"floorplan2.jpg"))

On the DraggableView I have:
B4X:
Sub Initialize(Activity As Activity, v As View)
   innerView = v
   panel1.Initialize("")
   panel1.Color = Colors.Transparent
   Activity.AddView(panel1, v.Left, v.Top, v.Width, v.Height)
   ACTION_DOWN = Activity.ACTION_DOWN
   ACTION_MOVE = Activity.ACTION_MOVE
   ACTION_UP = Activity.ACTION_UP
   Dim r As Reflector
   r.Target = panel1
   r.SetOnTouchListener("Panel1_Touch") 
   r.SetOnLongClickListener("Panel1_LongClick")      <<<<< ' This event is not fired
End Sub

Sub Panel1_LongClick
   
End Sub

The view drags ok but I need to be able to handle some click event on pabel1/p2.

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The problem is that the touch event consumes the touch gesture. One option is to analyze the touch sequence yourself and decide when to treat it as a movement and when to treat it as a long click.

Second option is to try to detect it with GestureDetector library. I'm not sure whether it will work with the touch event or not.
 
Upvote 0
Top