1

I have a native android library, Which expects a java function which works as an event. But in my nativescript plugin, I want to pass javascript function to the library so that library events are fired in javascript runtime.

Mehul Prajapati
  • 1,210
  • 2
  • 11
  • 29

1 Answers1

2

If your Java method expects an interface for callback functions, it's already covered in the NativeScript docs.

Java

button.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        // Perform action on click
    }
});

JavaScript

button.setOnClickListener(new android.view.View.OnClickListener({
    onClick: function() {
        // Perform action on click
    }
}));
Manoj
  • 21,753
  • 3
  • 20
  • 41