• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Closing Dialog when button clicked

superx335

Lurker
Dec 1, 2014
5
0
Hello!,

I am developing my first Android app and I have the first version almost finished, the problem is that I am stucked in a pretty stupid point…

The thing is the following, simplificating I’ve got an activity with a button, when button presed I open an Android dialog wich:

  • Capture a signature as bitmap
  • Present a “Reset” button that cleans the image to write again
  • Also a “Save” button which, onClick, saves the image as bitmap inside application folder
When I click outter the dialog, this is dismissed and in that event I can show the captured image in the main Activity as a little image (to see the signature), but I would like to dismiss the dialog at the same time when I press “Save” button.

The “problem” is that I don’t know where I have to use the event, I am guessing this has to be done in the main activity, but I don’t know how to catch an event of a button located in the Dialog and not the activity itself. And I think you can’t close the dialog itself catching the event inside the Dialog.

I found some code that shows how to access dialog button from main activity by using FindByView(R.id.BUTTON_IN_DIALOG) but an additional problem is that this “save” button I create it programatically in the moment of loading the dialog.

I hope you can give me a clue!.

Thanks so much in advance.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones