Does android: onClick use Java reflection concepts behind the scenes?

The question has been asked in many forms and many times here and here ; But I want to confirm one thing and my questions are very simple: Does android:onClick

Java use reflection?

Since Java reflection slows down performance as described here , I would never want to code inefficiently.

I just need a simple answer: yes (only if you are sure of it) or no?


There are many answers that SO contradict the understanding:

For example, see this and this one . Both accepted the answers and both say two different things. (that's just why I posted the question.)


source to share

2 answers

Indeed, it uses reflection to bind a method ("methodName") to a handler. This is a one-time XML bloat deal and does not impact performance in any meaningful way. XML inflation itself is quite expensive to parse,

(Per )

Also, it is exactly the same as doing it in code.



Until the delay in pressing the button reaches 1 / 10th of a second, people perceive it as instant , so optimizing the reflection of the response to the button press does not matter.

You don't need to worry about this issue so that optimization efforts can focus on code where there is a measurable performance issue.



All Articles