Android Question problem with click event in wrapping a lib

Discussion in 'Android Questions' started by mohammadreza hosseinzadeh, Aug 11, 2018.

  1. mohammadreza hosseinzadeh

    mohammadreza hosseinzadeh Member Licensed User

    hi there
    i use to wrap a lib from a java for b4a
    i made almost every thing make run
    but i stick in click event and enevt wont rasing

    here is my java onclick code

    Code:
    public void ClickListener() {
            CV.setOnClickListener(new 
    View.OnClickListener() {
               
                @Override
                
    public void onClick(View arg0) {
                    
    if(ba.subExists(eventName + "_Click")) {
                    ba.raiseEvent(
    null,eventName + "_Click" );
                    BA.Log(
    "lib:raising.."+eventName +"Clicked!");
                    
    }else {
                        BA.Log("SUB not made");
                    }
                }
            });
        }
    and here ive added event annotation
    @Events(values = { "Click" })

    and here is my b4a code
    Code:
    Sub Globals
     
        
    Dim btn As PSDEV_ProgressButton
    End Sub
    Sub Activity_Create(FirstTime As Boolean)
        btn.Initialize(
    "btn")
        
    Activity.AddView(btn,30%x,60%y,40%x,30dip)
    End Sub

    Sub btn_Click
        
    Log("Hi")
    End Sub
    and b4a logged SUB not made

    tnx for help in advance
     
  2. mohammadreza hosseinzadeh

    mohammadreza hosseinzadeh Member Licensed User

    im very sorry i found the soloution on forum
    i changed the raiser event to this
    Code:
    if (ba.subExists(eventName + "_click")) {
                getObject().setOnClickListener(new 
    View.OnClickListener() {

                    @Override
                    
    public void onClick(View v) {
                        ba.raiseEvent(getObject(), eventName + 
    "_click");
                    
    }

                });
            }
     
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