Reputation: 21
I Have an android activity with a custom view set to it. I need to access some activity variables in my View class. How can I do this?
Upvotes: 1
Views: 662
Reputation: 19273
your View should have Activity's context, so inside your CustomView
((MyActivity) getContext()).executeCustomMethod();
if you adding View in xml you can use for main parent view lines like this
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.test.MyActivity"
Upvotes: 1