locked
Xamarin - How to adapt Java Event and Listeners to C⧣ RRS feed

  • Question

  • User390048 posted

    so recently I had to work with an Android SDK that was built in Java, so I created a javabinding project and got the .dll file that I added to my Xamarin project later on as a reference.

    Now Im just trying to follow the "How to use" pdf that comes with it but Im kinda stuck in the part where I should register the EventListener. I know that there is no event keyword in Java. In Java you are essentially faking events and event handling by using a standard set of naming conventions.

    And on Xamarin documentation I found that :

    The Xamarin.Android Binding Generator will change some Java idioms and patterns to correspond to .NET patterns. The following list describes how Java is mapped to C#/.NET:

    • Setter/Getter methods in Java are Properties in .NET.

    • Fields in Java are Properties in .NET.

    • Listeners/Listener Interfaces in Java are Events in .NET. The parameters of methods in the callback interfaces will be represented by an EventArgs subclass.

    • A Static Nested class in Java is a Nested class in .NET.

    Here is the Java work in the pdf that I should convert :

    the confusion that I have is on the "printer.setReceiveEventListener(this);" "this" is an interface called IReceiverListener

    Can you please help me do things right ?

    Sunday, June 14, 2020 2:02 PM

All replies

  • User2148 posted

    Can you post the project on github?

    Something like printer.Receive +=….???

    Sunday, June 14, 2020 7:08 PM