android - Why is their Parameter of type View for an onClick Method -


.... android:onclick = "activity1"; ....  public void activity1(view view) {  ..... } 

why parameter function of type view

you can set onclicklistener on view. means that listener not know kind of element set listener on.

since elements can set onclicklistener on extend view, gives view because knows sure element view.

you can detect element clicked, , can cast specific element if want.


Comments

Popular posts from this blog

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

matlab - error with cyclic autocorrelation function -

php - Using grpc in Laravel, "Class 'Grpc\ChannelCredentials' not found." -