Android Question How to implement OnTouchListener in a costum view

PABLO2013

Well-Known Member
Licensed User
Longtime User
Greetings
I would like to know how you could implement an OnTouchListener event in a custom view, currently the graphical part works fine but the part of OnTouchListener is not how to make it work, thanks
B4X:
@BA.Version(1.0F)
@BA.ShortName("Croquis")
@BA.Events(values={"OnTouchListener (??????)"})


public class croquis extends ViewWrapper<DrawGrid> implements DesignerCustomView    {


     public void Initialize(BA paramBA, String       paramString)
      {
        _initialize(paramBA, null, paramString);
      }

      @BA.Hide
      public void _initialize(BA paramBA, Object paramObject, String     paramString)
      {
        this.eventName = paramString.toLowerCase(BA.cul);
        this.ba = paramBA;
        this.cv = new DrawGrid(paramBA.context);
       }

      
       public void DesignerCreateView(PanelWrapper paramPanelWrapper, LabelWrapper paramLabelWrapper, final Map paramMap)
      {
        ViewGroup localViewGroup = (ViewGroup)((ViewGroup)paramPanelWrapper.getObject()).getParent();
        AddToParent(localViewGroup, paramPanelWrapper.getLeft(), paramPanelWrapper.getTop(), paramPanelWrapper.getWidth(), paramPanelWrapper.getHeight());
        paramPanelWrapper.RemoveView();
  

        OnTouchListener cnvTouch = new View.OnTouchListener()
        {
        @Override
        public boolean onTouch(View arg0, MotionEvent arg1) {

          

            //my code

            ba.raiseEvent(this, eventName, paramMap);
      
            return false;
        }
        };
 
  
        paramPanelWrapper.AddView(cnvTouch, 0, 0, paramPanelWrapper.getWidth(), paramPanelWrapper.getHeight());
        paramPanelWrapper.setColor(Colors.Transparent);
  
  
  
        public View.OnTouchListener getCnvTouch() {
            return cnvTouch;


public void setCnvTouch(View.OnTouchListener cnvTouch) {
            this.cnvTouch = cnvTouch;
        }
        }



costum=custom,sorry
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…