How exactly does the android:onClick XML attribute differ from setOnClickListener?

后端 未结 17 2116
野趣味
野趣味 2020-11-21 11:50

From that I\'ve read you can assign a onClick handler to a button in two ways.

Using the android:onClick XML attribute where you just use t

17条回答
  •  天涯浪人
    2020-11-21 12:27

    There are very well answers here, but I want to add one line:

    In android:onclick in XML, Android uses java reflection behind the scene to handle this.

    And as explained here, reflection always slows down the performance. (especially on Dalvik VM). Registering onClickListener is a better way.

提交回复
热议问题