C# Xamarin OnClick function

前端 未结 3 447

What I\'m doing is this

Button button1 = FindViewById
3条回答
  •  南笙
    南笙 (楼主)
    2021-01-02 08:37

    No need of using either delegates or c# style events, you can use both depending on the class being used. Remember that the View.IOnclicklistener is an interface so inherit from it like so,

    public class myactivity : AppcompatActivity, View.IonClickListener
    

    It prompts you to implement the onclick method of the interface like below,,

    public void OnClick(View v)
            {
                throw new NotImplementedException();
            }
    

    You can use a mixture of c# style events and event listeners. What java can do Xamarin can do ..This is the correct answer to this question i believe..

提交回复
热议问题