Search code examples
androidfindviewbyidbutterknife

Does findViewById has priority over ButterKnife's bind method call?


In my activity's onCreateView I have two different source views to inflate UI elements. So I am inflating all the UI elements that belong to one source view by findViewById() and those that belong to the other source view using ButterKnife's Bind method call.

But this will work only if findViewById has priority over ButterKnife, otherwise first set of elements would also get attached to the second source view.

So is it true that findViewById has priority over ButterKnife?


Solution

  • Under the hood ButterKnife's Bind is being executed as findViewById with an integer value of the id, rather than the lookup R.id.something, this means that both methods are actually performing the same and have the same "priority", it just depends which one you execute first.

    So the answer is "no, ButterKnife's Bind has no priority, though the execution can be a bit faster due to the lookup"