views:

52

answers:

1

I have an Android activity running with a custom view in it. When something happens within that custom view, I want to tell the currently running activity by changing one of the Activity member variables. Is there a way to access the current running activity member variables from within a custom view class besides passing the activity into the view class though a function arg?

Thanks

+1  A: 

In your case, getContext() in a View will return the Activity that created the View.

CommonsWare
When I'm inside the view and I call getContext() and cast it to an Activity variable, the IntelliSense doesn't let me access any of my custom methods or member variables. Eclipse also won't let me compile if I try to reference any of those activity member vars or functions because it doesn't know about them before the code is run :S
justinl
Your custom variables aren't members of `Activity`. You should cast the `Context` to `YourActivity`, not just `Activity`
benvd
Ahhh thanks! Works great
justinl