How Do I Reference The Main Activity's Onclick From Within The Onclick Method Of A Dialog... Or Can I?
I am trying to do something unusual. I have a main activity with a menu attached to the menu button. One item in the menu opens a dialog to pick a control that is added to the ma
Solution 1:
Why do you need specific access to the onClick()
method? Just create a public method in your main
class and call it from both the dialog and the button's onClick()
methods. Sadly DialogInterface and View don't share a superclass, but you can pass the Object and cast accordingly if necessary.
Solution 2:
As suggested by Selvin in the comments, I needed to set the onClickListener using: MyMainActivity.onClick
Post a Comment for "How Do I Reference The Main Activity's Onclick From Within The Onclick Method Of A Dialog... Or Can I?"