 <p>you may also add Method to Button for onClick in xml and use the same method in activity.As,</p> <pre><code>private void blabla(view v){ if(v= ui_titlebar_back_btn){ //do something } else if(v==blabla){ //do something } } </code></pre>