not really following this, I have a trail verson wanting to see this program is going to do what I want to before I buy it. The trail verson come with little to no documentation, and you can't creat a module within it.
right with code about (mins the part unloading) I can a second layout to open, but it opens on top the first one. I just want to blow the way the first one some how.
Well, it looks like this trial version isn't going to let me do this, I was hoping to two layouts under one activity cause it's all the trial version lets you have one activity, not two...grr annoying, they should made the trial version do everything except buid the .ark file, like a student copy of vb does
You can load the layout to a panel and then add this panel to the activity.
Later you can remove the existing panel and create a new one with a new layout.
B4X:
Sub Globals
Dim Panel1 As Panel
End Sub
Sub Activity_Create (FirstTime As Boolean)
LoadLayoutToPanel("layout1")
End Sub
Sub LoadLayoutToPanel (Layout As String)
If Panel1.IsInitialized then
Activity.RemoveViewAt(0)
End If
Panel1.Initialize("")
Panel1.LoadLayout(Layout)
Activity.AddView(Panel1, 0, 0, 100%x, 100%y)
End Sub
I think this is just what I needed. I added a settings button to the basic Hello World turtorial, to take me to a different "page". This solution above works perfectly (I had both layouts over top of each other previously).
However, when I hit the back arrow in the AVD, it just closes the app completely, rather than return to the hello world page as I would expect. Can I catch that event somehow or do I need a different structure? . Would the proper way to go be to create a second activity instead of this view method? This is my first mobile app.
Never mind. I found the answer. To future lurkers:
I abandoned the strategy above, and went with a second activity. In the button event to get to the second activity, I used this instead StartActivity("settings"). Now back button works fine.
Found in this tutorial (Sorry, it won't let me post a link)
19514-problems-app-closing-back-button-press-tutorial
I used Erel's suggestion above. When I load the 1st layout, it works fine. But when I try to load the 2nd layout, I get an error:
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
I tried, adding Activity.RemoveView right after the Activity.RemoveViewAt(0) in the If condition, however, it still gives the same error.
Whithout knowing your code and what you have in the layout files impossible to help you.
Post your project as a zip file (IDE menu Files / Expost As Zip) so we could look at it.
I used Erel's suggestion above. When I load the 1st layout, it works fine. But when I try to load the 2nd layout, I get an error:
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
I tried, adding Activity.RemoveView right after the Activity.RemoveViewAt(0) in the If condition, however, it still gives the same error.
Sorry that I re-open this post but I have the same problem. I try the solution of mc73, but still not work.
Error message is: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
Hier my code:
Sub Globals
Private Panel1 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("frmMainNVision")
LoadLayoutToPanel("frmMainNVision")
End Sub
Sub LoadLayoutToPanel (Layout As String)
If Panel1.IsInitialized Then
Panel1.RemoveView()
End If
Panel1.Initialize("")
Panel1.LoadLayout(Layout)
Activity.AddView(Panel1, 0, 0, 100%x, 100%y)
End Sub