Which One Is Better Performance Wise: setOnClickListener VS android:onclick="onClick"
android, onclicklistener, performance
Solution
Both are the same in performance. Xml is pre-parsed into binary code while compiling. so there is no over-head in Xml.
Problem
In Android we have 2 ways to set an onClick event for a buttom (or any other view I think): Scenario one (programmatically): ``` Button b = (Button) findViewById(R.id.mybutton); b.setOnClickListener(this); ``` Scenario two (in the XML file): ``` <Button android:onClick="handler" /> ``` Is there any performance penalty for doing this in XML or programmatically or is it the same?