Mohammadreza Member Dec 10, 2013 #1 I’m making a simple application (my first app) and I’m a beginner. In my app, when I press back button, its exit from app. Which code should I write to solve this problem and when I press back button, it loads my first layout. also i used this code, but in doesnt work. B4X: Sub Activity_KeyPress (KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then Activity.LoadLayout("1") End If End Sub Sorry for my bad English.
I’m making a simple application (my first app) and I’m a beginner. In my app, when I press back button, its exit from app. Which code should I write to solve this problem and when I press back button, it loads my first layout. also i used this code, but in doesnt work. B4X: Sub Activity_KeyPress (KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then Activity.LoadLayout("1") End If End Sub Sorry for my bad English.
Erel B4X founder Staff member Licensed User Longtime User Dec 11, 2013 #2 Add 'Return True'. Upvote 0
Mohammadreza Member Dec 13, 2013 #3 Erel said: Add 'Return True'. Click to expand... Tanx for your help. I do this, but now it doesn,t go back - stay on selected layout. I just want to use back buttun to return to first layout. Upvote 0
Erel said: Add 'Return True'. Click to expand... Tanx for your help. I do this, but now it doesn,t go back - stay on selected layout. I just want to use back buttun to return to first layout.
Erel B4X founder Staff member Licensed User Longtime User Dec 15, 2013 #4 Your app is built incorrectly. You should not load the layout when the user presses on the back key. See this example: Two activities example Upvote 0
Your app is built incorrectly. You should not load the layout when the user presses on the back key. See this example: Two activities example