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?

EDIT

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.)

+3


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 http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.1_r2/android/view/View.java#2017 )



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

+2


source


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.

+1


source







All Articles