Android Question Trap KeyPress in class

joneden

Active Member
Licensed 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
 

AndOrNot

Well-Known Member
Licensed User
I think you can use activity keypress event, e when the back key is pressed you should set unvisible the custom panel, or remove the panel.
I hope that you understand what i mean
 
Upvote 0

joneden

Active Member
Licensed 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

AndOrNot

Well-Known Member
Licensed User
I use appcompact to set material design and material theme, so i have a lollipop real device and custom dialogs are very nice (in my device :D).. i think that best popup box are simple panel with title, a text, 2 labels used as button and a semi transparent background :D
 
Upvote 0

joneden

Active Member
Licensed 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