Android Question Newbie query

OscarB

New Member
Licensed User
Longtime User
I have very limited programming experience. I am building my first app and am getting there slowly but surely.

I am stuck with trying to do something quite simple. I want to capture a short string of text (no more than 11 characters, mixture of numbers and letters) which the user types in. This string is then displayed in the form of a label on various other layouts.

I have been struggling to do this but have attached the file with comments in Caps - would appreciate if someone could point me in the right direction.

I am still pretty new to programming, so although I understand concepts of if, elses etc I struggle with types, classes, parsing etc. Any tips for the best way to understand what these concepts mean in order to make more sense of the huge amount of resources in the forums and documentation?
 

Attachments

  • oscarb1.zip
    12.2 KB · Views: 185
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
You just need to pass the value to the label text property:
B4X:
Sub btngo2Rate_Click
                                                       'HOW DO I CAPTURE THE EDITTEXT ENTRY AND DISPLAY IT IN THE LABEL IN THIS LAYOUT?
   If enterTaxiReg.Text = "" Then
     Msgbox("No registration entered", "please try again")
   Else
   
   Activity.RemoveAllViews
   Activity.LoadLayout("layoutRate")
   lblExit.Text = enterTaxiReg.Text '<-----   
   End If
End Sub

I recommend you to use multiple activities instead of switching the layout of the current activity.
 
Upvote 0

OscarB

New Member
Licensed User
Longtime User
Excellent, it worked. Thank you!

I was using the correct code, but I think I was placing it in the wrong place i.e. before the view was loaded. Is that the general rule i.e. first load the layout, then assign all the values to the buttons/labels etc?

Re your comment on activities vs views: Am I right in thinking that for each activity I would then hide and unhide buttons, labels etc depending on the Activity to give the effect of switching screens, rather than loading the buttons etc in a new layout every time?
 
Upvote 0
Top