EditText Question

erickwesz

Member
Licensed User
Longtime User
Hi guys, :sign0104: asking..

how do i get the result from this?

B4X:
'This is the Main Module
Sub Process_Globals

End Sub

Sub Globals
   
   Dim FormPanel As Panel
   
End Sub

Sub Activity_Create(FirstTime As Boolean)

   Activity.Title = "Test Form"
   
   FormPanel.Initialize("FormPanel")
   Activity.AddView(FormPanel, 5%x, 5%y, 90%x, 90%y)
   
   Dim FormList As List
   FormList.Initialize
        'Label name, Hint, Initialize Name, Type
   FormList.add(Array As String("Name :", "Your Name", "name", "text"))
   FormList.add(Array As String("Address :", "Your Address", "address", "multitext"))
   FormList.add(Array As String("Phone :", "Your Phone Number", "phone", "phone"))
   FormList.add(Array As String("", "Clear", "Save", "button"))
   
   Functions.PrintForm(FormList, FormPanel)
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub clearbtn_click

   
End Sub

Sub savebtn_click
   
   
End Sub

B4X:
'Functions Code Module

Sub Process_Globals

End Sub

Sub PrintForm(FList As List, PNL As Panel)

   Dim FEachHeight, FEachTop As Int
   FEachTop = 15
   
   For i = 0 To FList.Size - 1
      Dim FEach() As String
      FEach = FList.Get(i)
      FEachHeight = 60
      
      If FEach(3) = "button" Then
         Dim BtnWidth, BtnLeft As Int
         BtnWidth = (PNL.Width * 80 / 100) * 25 / 100
         BtnLeft = PNL.Width * 20 / 100
         For j = 0 To 2
            If FEach(j) <> "" Then
               Dim button1 As Button
               Select FEach(j)
                  Case "Cancel"
                     button1.Initialize("cancelbtn")
                  Case "Clear"
                     button1.Initialize("clearbtn")
                  Case "Save"
                     button1.Initialize("savebtn")
               End Select
               button1.Text = FEach(j)
               PNL.AddView(button1, BtnLeft, FEachTop, BtnWidth, FEachHeight)
               BtnLeft = BtnLeft + BtnWidth + 5
            End If
         Next
         FEachTop = FEachTop + FEachHeight + 10
      Else   
         Dim label1 As Label
         Dim edittext1 As EditText
         
         label1.Initialize("formlabel")
         label1.Text = FEach(0)
         label1.Gravity = Gravity.CENTER_VERTICAL
         label1.TextSize = 18
         
         edittext1.Initialize(FEach(2))
         
         Select FEach(3)
            Case "text"
               edittext1.InputType = edittext1.INPUT_TYPE_TEXT
            Case "multitext"
               edittext1.InputType = edittext1.INPUT_TYPE_TEXT
               edittext1.SingleLine = False
               FEachHeight = 180
            Case "phone"
               edittext1.InputType = edittext1.INPUT_TYPE_PHONE
            Case "number"
               edittext1.InputType = edittext1.INPUT_TYPE_NUMBERS
         End Select
         
         edittext1.Hint = FEach(1)
         
         PNL.AddView(label1, 0, FEachTop, PNL.Width*20/100, FEachHeight)
         PNL.AddView(edittext1, PNL.Width*20/100, FEachTop, PNL.Width*80/100, FEachHeight)
         
         FEachTop = FEachTop + FEachHeight + 10
      End If
   Next
      
End Sub

how do i get each EditText value when i press save?
I've tried to call "name.Text", or "edittext1.text" but it seems the edittext haven't been initialized yet from the main module..

The only way i can get the value is by capturing the TextChanged event..
But this is not what i want, and it was a little bit slow..

Please Help

Sorry for my bad English, Hope you guys understand what i mean..

Thanks
 
Last edited:

erickwesz

Member
Licensed User
Longtime User
Im currently making a lot of form pages which i guess it will be much easier to have a sub on my code module to generate it from me based on a list and i need to access it from my activity module.

Now Im using textchanged event to get the value of each edittext. Is there any other ways to do that?
And another problem is i cant clear the edittext from my activity module. It seems the edittext is not initialized..
 
Upvote 0

erickwesz

Member
Licensed User
Longtime User
at first i thought creating it programatically will be easier to customize since im planning to use it on several different resolution. well i guess it gave me another problem lol.

anyway thanks a lot for the reply erel, i think im going to create several layout and use them instead.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…