Android Question Function of Page 2 module/Solved

Shelby

Active Member
Licensed User
Hi People,
I guess I've waited long enough without help and would like to ask for some, to solve my problem of my second page not functioning. When I do a simple math calculation on my main page I click a button at the bottom of the screen to move to page 2 to do the same calculation on the second room of a building. Page 2 takes the length and width but stops there instead of logging on the IDE or showing on the page 2. I think I'm close but without a cigar.
Any suggestions?
Thanks
P.S. the whole app is zipped below. Also if I copy the code from page 2 and let it stand alone in a new B4A project it works properly.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout_Page_2")
    pnlBitmap2.Initialize ("")
    Activity.AddView (pnlBitmap2, 10%x, 270dip,70%y, 200dip)
    Private bdwBitmap2 As BitmapDrawable
    bdwBitmap2.Initialize(LoadBitmap(File.DirAssets, "framing.jpg"))
    bdwBitmap2.Gravity = Gravity.FILL
    pnlBitmap2.Background = bdwBitmap2
  
  
End Sub


Sub btnCalc2_Click
    Result2 = edtLen2.Text * edtWidth2.Text
    lblResult2.Text = Result2 & "     Square Feet"
    Log(Result2 & " Sq Ft")
  
End Sub


Sub lblNext2_click
  
    Activity.RemoveAllViews
    Activity.LoadLayout("Layout_Page_3")
  
End Sub
 

Attachments

Last edited:

walterf25

Expert
Licensed User
Hi People,
I guess I've waited long enough without help and would like to ask for some, to solve my problem of my second page not functioning. When I do a simple math calculation on my main page I click a button at the bottom of the screen to move to page 2 to do the same calculation on the second room of a building. Page 2 takes the length and width but stops there instead of logging on the IDE or showing on the page 2. I think I'm close but without a cigar.
Any suggestions?
Thanks
P.S. the whole app is zipped below.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout_Page_2")
    pnlBitmap2.Initialize ("")
    Activity.AddView (pnlBitmap2, 10%x, 270dip,70%y, 200dip)
    Private bdwBitmap2 As BitmapDrawable
    bdwBitmap2.Initialize(LoadBitmap(File.DirAssets, "framing.jpg"))
    bdwBitmap2.Gravity = Gravity.FILL
    pnlBitmap2.Background = bdwBitmap2
  
  
End Sub


Sub btnCalc2_Click
    Result2 = edtLen2.Text * edtWidth2.Text
    lblResult2.Text = Result2 & "     Square Feet"
    Log(Result2 & " Sq Ft")
  
End Sub


Sub lblNext2_click
  
    Activity.RemoveAllViews
    Activity.LoadLayout("Layout_Page_3")
  
End Sub
What is the error, are there any errors in the Logs?

Walter
 

Shelby

Active Member
Licensed User
I'll check now. Running.......... No error. I just get no results when I click to calculate on page 2. Also nothing shows in the logs when I try on page 2.
 

walterf25

Expert
Licensed User
Hi People,
I guess I've waited long enough without help and would like to ask for some, to solve my problem of my second page not functioning. When I do a simple math calculation on my main page I click a button at the bottom of the screen to move to page 2 to do the same calculation on the second room of a building. Page 2 takes the length and width but stops there instead of logging on the IDE or showing on the page 2. I think I'm close but without a cigar.
Any suggestions?
Thanks
P.S. the whole app is zipped below. Also if I copy the code from page 2 and let it stand alone in a new B4A project it works properly.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout_Page_2")
    pnlBitmap2.Initialize ("")
    Activity.AddView (pnlBitmap2, 10%x, 270dip,70%y, 200dip)
    Private bdwBitmap2 As BitmapDrawable
    bdwBitmap2.Initialize(LoadBitmap(File.DirAssets, "framing.jpg"))
    bdwBitmap2.Gravity = Gravity.FILL
    pnlBitmap2.Background = bdwBitmap2
 
 
End Sub


Sub btnCalc2_Click
    Result2 = edtLen2.Text * edtWidth2.Text
    lblResult2.Text = Result2 & "     Square Feet"
    Log(Result2 & " Sq Ft")
 
End Sub


Sub lblNext2_click
 
    Activity.RemoveAllViews
    Activity.LoadLayout("Layout_Page_3")
 
End Sub
I see what the problem is:

You are loading the layout for the second screen from the Main activity, this won't work because you don't have the views in the Layout_page2 layout declared in the Main activity, what you want to do is call the page2 activity instead.

Instead of this
B4X:
Sub lblNext_click
    
    Activity.RemoveAllViews
    Activity.LoadLayout("Layout_Page_2")
    
End Sub
Do this instead
B4X:
Sub lblNext_click
    
StartActivity(Page2)
    
End Sub
Walter
 

Shelby

Active Member
Licensed User
Thanks, I have watched nearly every tutorial unless there have been a number of them newly made in the last few months. I'll check the one you suggested above. I find that generally speaking the tutorials are far advanced for a person like myself who has started 15 months ago and simply have read as much as I can including the Seagrave book and hundreds of solutions on the forum. When I finish the Seagrave book I intend to start the book from Vision College called "Visual Basic For Android".
 
Last edited:
Top