Android Question Edit Text Problem.

Sreenadh OG

Member
Licensed User
Longtime User
Hi All,
I have a panel contain some EditText and Lable, But i cant enter text in EditText, I am using given code ..

B4X:
'    PnlDialogAccCmp.AddView(LblDialogAccName,10,0,60,18)
'    PnlDialogAccCmp.AddView(EditDlgAcusedName,60,0,120,28)
'    PnlDialogAccCmp.AddView(LblDialogAccPh,10,43,60,18) 
'    PnlDialogAccCmp.AddView(EditDlgAccPh,60,40,120,28) 
'    PnlDialogAccCmp.AddView(LvDialogAccPerson,10,65,190,70) 
'    CstmDigAddAcdNewPesrn.AddView(PnlDialogAccCmp,10,0, 77%x, 60%y )
'    

'I cant enter text in EditDlgAccPh ,But the code given above works properly
    PnlDialogAccCmp.AddView(LblDialogAccName,5%x,0%x,30%x,10%x)
    PnlDialogAccCmp.AddView(EditDlgAcusedName,25%x,0%x,43%x,12%x)
    PnlDialogAccCmp.AddView(LblDialogAccPh,5%x,18%x,30%x,10%x)
    PnlDialogAccCmp.AddView(EditDlgAccPh,25%x,18%x,43%x,12%x)
    PnlDialogAccCmp.AddView(LvDialogAccPerson,5%x,19%x,80%x,50%x) 
    CstmDigAddAcdNewPesrn.AddView(PnlDialogAccCmp,10,0, 77%x, 60%y )
 

Sreenadh OG

Member
Licensed User
Longtime User
B4X:
Sub BtnAddAccusedNew_Click
Dim CstmDigAddAcdNewPesrn As CustomDialog
Dim EditDlgAcusedName As EditText     
    Dim EditDlgAccPh As EditText
    Dim LblDialogAccName As Label
    Dim LblDialogAccPh As Label
    Dim PnlDialogAccCmp As Panel
    Dim LvDialogAccPerson As ListView
    Dim BmpDialogAddPersn As Bitmap
    LvDialogAccPerson.Initialize("LvDialogAccPerson")
    If Acc > 0 Then
        For NoAcused=0 To RangeForAcused-1
            LvDialogAccPerson.AddSingleLine(AccusedStrName(NoAcused)&"  "&AccusedPh(NoAcused))
        Next
    End If
    EditDlgAcusedName.Initialize("EditDlgAcusedName")
    EditDlgAccPh.Initialize("EditDlgAccPh") 
    EditDlgAcusedName.InputType=EditDlgAcusedName.INPUT_TYPE_NONE   
    EditDlgAccPh.InputType=EditDlgAccPh.INPUT_TYPE_PHONE  
    LblDialogAccPh.Initialize("LblDialogAccPh")
    LblDialogAccName.Initialize("LblDialogAccName")
    PnlDialogAccCmp.Initialize("Panel1")
    LblDialogAccName.Text="Name"
    LblDialogAccName.TextColor=Colors.White 
    LblDialogAccName.TextSize=20
    LblDialogAccPh.Text="Phone" 
    LblDialogAccPh.TextColor=Colors.White 
    LblDialogAccPh.TextSize=20 

'    PnlDialogAccCmp.AddView(LblDialogAccName,10,0,60,18)
'    PnlDialogAccCmp.AddView(EditDlgAcusedName,60,0,120,28)
'    PnlDialogAccCmp.AddView(LblDialogAccPh,10,43,60,18) 
'    PnlDialogAccCmp.AddView(EditDlgAccPh,60,40,120,28) 
'    PnlDialogAccCmp.AddView(LvDialogAccPerson,10,65,190,70) 
'    CstmDigAddAcdNewPesrn.AddView(PnlDialogAccCmp,10,0, 77%x, 60%y )
'   
    PnlDialogAccCmp.AddView(LblDialogAccName,5%x,0%x,30%x,10%x)
    PnlDialogAccCmp.AddView(EditDlgAcusedName,25%x,0%x,43%x,12%x)
    PnlDialogAccCmp.AddView(LblDialogAccPh,5%x,18%x,30%x,10%x)
    PnlDialogAccCmp.AddView(EditDlgAccPh,25%x,18%x,43%x,12%x)
    PnlDialogAccCmp.AddView(LvDialogAccPerson,5%x,19%x,80%x,50%x) 
    CstmDigAddAcdNewPesrn.AddView(PnlDialogAccCmp,10,0, 77%x, 60%y 
   
    BmpDialogAddPersn.Initialize(File.DirAssets,"AddNewPerson.png") 
    ret = CstmDigAddAcdNewPesrn.Show("Add Contact", "Add", "Cancel","" , BmpDialogAddPersn)
    If EditDlgAcusedName.Text <>"" AND EditDlgAccPh.Text <>"" Then  
        AccusedStrName(NoAcused)=EditDlgAcusedName.Text
        AccusedPh(NoAcused)=EditDlgAccPh.Text    
        LvDialogAccPerson.AddSingleLine(AccusedStrName(NoAcused)&"   "&AccusedPh(NoAcused))
        NoAcused=NoAcused+1
        RangeForAcused = NoAcused
        Acc=Acc+1
    End If
ScrollInitializeNewCase
End Sub
 
Upvote 0

Sreenadh OG

Member
Licensed User
Longtime User
But i can enter a text in first Edittext and i can also edit both Edittext without using percentage..How it is possible?
 
Upvote 0

Sreenadh OG

Member
Licensed User
Longtime User
hai,
Now i am using panel in front of all the other views, but i didn't get text from EditText. How can i get the text from EditText ?
My code is ..
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
   
    Dim LvDialogAccPerson As ListView
    Private Panel1 As Panel
    Private Button1 As Button
    Private BtnAddPersnAccused As Button
    Private BtnCancelPersonAccused As Button
    Private EditDlgAccPh As EditText
    Private EditDlgAcusedName As EditText
    Private LblDialogAccName As Label
    Private LblDialogAccPh As Label
    Private PnlDialogAccCmp As Panel
    Private EditText1 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
   
    Activity.LoadLayout("La")
   
    Dim BmpDialogAddPersn As Bitmap
    LvDialogAccPerson.Initialize("LvDialogAccPerson")
   
    EditDlgAcusedName.Initialize("EditDlgAcusedName")
    EditDlgAccPh.Initialize("EditDlgAccPh") 
    EditDlgAcusedName.InputType=EditDlgAcusedName.INPUT_TYPE_NONE   
    EditDlgAccPh.InputType=EditDlgAccPh.INPUT_TYPE_PHONE  
    LblDialogAccPh.Initialize("LblDialogAccPh")
    LblDialogAccName.Initialize("LblDialogAccName")
    PnlDialogAccCmp.Initialize("PnlDialogAccCmp")
    LblDialogAccName.Text="Name"
    LblDialogAccName.TextColor=Colors.White 
    LblDialogAccName.TextSize=20
    LblDialogAccPh.Text="Phone" 
    LblDialogAccPh.TextColor=Colors.White 
    LblDialogAccPh.TextSize=20 
    BtnAddPersnAccused.Initialize("BtnAddPersnAccused") 
    BtnCancelPersonAccused.Initialize("BtnCancelPersonAccused")
   


    PnlDialogAccCmp.AddView(LblDialogAccName,5%x,0%x,30%x,10%x)
    PnlDialogAccCmp.AddView(EditDlgAcusedName,25%x,0%x,43%x,12%x)
    PnlDialogAccCmp.AddView(LblDialogAccPh,5%x,18%x,30%x,10%x)
    PnlDialogAccCmp.AddView(EditDlgAccPh,25%x,18%x,43%x,12%x)
    PnlDialogAccCmp.AddView(LvDialogAccPerson,5%x,19%x,80%x,50%x)
    PnlDialogAccCmp.AddView(BtnAddPersnAccused,5%x,20%x,30%x,12%x)
    PnlDialogAccCmp.AddView(BtnCancelPersonAccused,25%x,20%x,30%x,12%x)    
End Sub
Sub Activity_Resume

End Sub
Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub BtnAddPersnAccused_Click
    Dim a As String
    Dim b As String
     a=EditDlgAcusedName.Text   'Here i didn't get the text 
     b=EditText1.Text     
End Sub
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
The problem is that you load a layout and then you initialize new instances of all views and add them to PnlDialogAccCmp which is not added to the activity.
You should remove everything in Activity_Create, only leave Activity.LoadLayout("Layout1") !
If you need to adjust the view positions you should do it in DesignerScripts.
 
Upvote 0
Top