Did you finally get the correct answer? the proposed solution isn't working for me also
How to rename the Event Name in xamarin.android binding?
I am binding an .aar
to android and there is one Event I have to change its name.
public event EventHandler<global::Com.xxx.xxx.A.BEventArgs> B{}
I want to change the name of B
but I can not . how to change it?
the interfaces of java is:
public static interface OnBListener{ void OnB(); }
there is a region #region "Event implementation for IOnBListener"
in the cs code.
Developer technologies .NET Xamarin
3 answers
Sort by: Most helpful
-
-
NullObjectReference 1 Reputation point
2022-06-14T22:25:58.507+00:00 @mc , @Zola
The only way to change event name that works for me is changing of managed name of correspondingsetEventListener
mathod.
So if you have java sources/// Listener interface public interface OnBListener { void onB(); }
And
// Listener consumer class public class ListenerConsumer { public void setOnBListener(OnBListener listener) { } }
You can change managed name of
ListenerConsumer.setOnBListener
:<attr path="/api/package[@name='com.xxx.xxx']/class[@name='ListenerConsumer']/method[@name='setOnBListener']" name="managedName">SetOnDListener</attr>
In this case name of generated event in C# code will be
D
instead ofB
. -
NullObjectReference 1 Reputation point
2022-06-18T14:17:41.7+00:00 Finally I found correct way to control generated event names.
name="eventName"
attribute can be applied to correspondingsetOnListener
method. For example:<attr path="/api/package[@name='com.xxx.xxx']/class[@name='ListenerConsumer']/method[@name='setOnBListener']" name="eventName">D</attr>
will produce in generated C# code
D
event.