I tried to intercept Back button it works but at the end it exits the app. How to avoid this:sign0085:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event
Dim KC As Boolean
If KeyCode = 4 Then KC = True
If KC=True Then
panel2.Visible=False
panel1.Visible=True
End If
End Sub
The clue is in the comment:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
'return true if you want to consume the event
Before your (second) End If you need to add:
Return True
This stops the OS from dealing with the keypress, so the app will not stop.
BTW, your code would be much neater as:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event
If KeyCode = 4 Then
panel2.Visible=False
panel1.Visible=True
Return True
End If
End Sub
As KC is not really needed.