Getting activity from context in android
From your Activity, just pass in this as the Context for your layout: Afterwards you will have a Context in the layout, but you will know it is actually your Activity and you can cast it so that you have what you need: