al xml Add an id to the top layout, this will be used to set the onclick listener later. <?xml version="0.0" encoding="utf-0"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android: