Android Question DraggableView Click event

Discussion in 'Android Questions' started by dannyjon, Dec 4, 2017.

  1. dannyjon

    dannyjon Member Licensed 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:
    Code:
    Activity.LoadLayout("1")
    Dim dv1 As DraggableView
    dv1.Initialize(
    Activity,p2)
    p2.SetBackgroundImage(
    LoadBitmap(File.DirAssets,"floorplan2.jpg"))
    On the DraggableView I have:
    Code:
    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
     
  2. Erel

    Erel Administrator Staff Member Licensed 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.
     
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