Android Question Trap KeyPress in class

joneden

Active Member
Licensed User
Longtime User
Hi All,

I've done a material styled custom dialog as a class. It works quite well and allows me to supply a preconfigured panel to it that drops into the middle of the dialog. The one issue I have is that when it is visible on an activity and the user presses the back button the Activity_KeyPress event is raised.
I can put some form of check into that event so that a function in the class is called if it is active however it would be nice if there was a way to do the KeyPress event within the class. Is that possible or am I stuck using the Activity KeyPress event?

Regards

Jon
 

joneden

Active Member
Licensed User
Longtime User
Yeah thats pretty much where I was going with my backup method. Slightly messier than I wanted but it will work. All to get a decent looking popup box :)
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Yeah thats pretty much where I went except that I do the 3 button approach when needed. I copied the guidelines so it's pretty close to the proper layout.

I found that the standard dialog library that allowed me to use custom dialogs ended up showing a nice panel BUT there was an underlying panel on pre lolipop devices that helped it with the display of the shadow, it looked a bit weird. The only isue that i had was that I need to wrap pre sdk21 in a cardview as I can't set elevation for panels. I could use a card view post sdk21 but I decided to do it properly where possible :)
 
Upvote 0
Top