How is using OnClickListener interface different via XML and Java code? [duplicate]
These are exactly the same. android:onClick was added in API level 4 to make it easier, more Javascript-web-like, and drive everything from the XML. What it does internally is add an OnClickListener on the Button, which calls your DoIt method. Here is what using a android:onClick=”DoIt” does internally: Button button= (Button) findViewById(R.id.buttonId); button.setOnClickListener(new View.OnClickListener() { … Read more