iOS Question problem with tag and sender in textFiled

mohammadreza hosseinzadeh

Member
Licensed User
hello all

im getting problem in tag and sender in textFileld
i set tag some where like
B4X:
ET_EnterText=i
'its in loop and multipanels

Sub ET_TextChanged (OldText As String, NewText As String)
dim et as textfield=sender
log(et.tag)
End Sub
but its return null
i tried to log after seting the tag and its worked
tnx in advance
 

mohammadreza hosseinzadeh

Member
Licensed User
We cannot say anything without seeing the code...

Where is the tag set?

How is the layout created?


layout created with multi panel
scroll view in designer and other views generated with code
here is a full code module
B4X:
Sub Process_Globals
    Dim matnp As Page
    Dim sql1 As SQL
    Dim matndb As SQL
    Dim PNL_ActionBar As Panel
    Dim BTN_Continue As Panel
    Dim txtdownloader As HttpJob
    Dim tst As HUD
    Dim PNL_Container As Panel
    Dim img1,img2 As ImageView
    Dim TITLE As Label
    Private SV_MENU As ScrollView
    Dim row(),field() As String
    Dim top As Int=10dip
    Dim PNL_Pretext(100) ,PNL_EnterText(100) As Panel
    Dim priceselect As Label
    Dim cur As ResultSet
    Dim BTN_pnl1(100),BTN_pnl2(100) As ImageView
    Dim LBL_pnl1,LBL_pnl2,LBL_Limit,LBL_Counter(100)  As Label
    Dim ET_EnterText(100) As TextField
    Dim texts(100) As String
    Dim diff(100,100) ,lastpriceid,lasttedad,priceid(100) As Int
    Dim list1 As List
    Private TITLE As Label
    Dim steps As stepbar
    Private btn_text As Label
    Dim AC As ActionBar
    Private PNL_Stepbar As Panel
    Dim way As Settings
 
    Dim spiner(100) As spinner
    Dim arrow(100) , arrow2(100) As ImageView
Dim tager As Int
End Sub
Sub show
    If matnp.IsInitialized = False Then
        matnp.Initialize("mainp")
        matnp.RootPanel.Color=Colors.White
        Main.NavControl.ShowPage(matnp)
 
    End If
 
    matnp.RootPanel.LoadLayout("matn_lay")
    matnp.RootPanel.Color=Colors.rgb(238,242,243)
 
 
    BTN_Continue.Color=Colors.rgb(103,188,103)
 
    btn_text.Text="Submit
    btn_text.Font=Font.CreateNew2("YekanMobileFaNum",16)
    btn_text.TextColor=Colors.White
    AC.Initialize(PNL_ActionBar,TITLE,"oncardimg")
 
    'add stepmeter
 
    steps.Initialize(PNL_Stepbar)
    steps.addstep("checked.png","checked.png","stephalf.png","cir4no.png","cir5no.png")
 
    SV_MENU.ContentWidth=100%x
    SV_MENU.Color=Colors.rgb(238,242,241)
    SV_MENU.Panel.Color=Colors.rgb(238,242,241)
    If File.Exists(File.DirLibrary , "matn.db") = False Then
        File.Copy(File.DirAssets , "matn.db" , File.DirLibrary , "matn.db")
    Else
        File.Delete(File.DirLibrary,"matn.db")
        File.Copy(File.DirAssets , "matn.db" , File.DirLibrary , "matn.db")
    End If
 
    matndb.Initialize(File.DirLibrary,"matn.db",False)
 
    txtdownloader.Initialize("txtdownloader",Me)
    txtdownloader.Download("http://...")
 
    tst.ProgressDialogShow("wait a moment")
    Wait For (txtdownloader) JobDone (job As HttpJob)
    If job.Success=True Then
        tst.ProgressDialogHide
    End If
    sql1.Initialize(File.DirLibrary,"price.db",False)
    cur=sql1.ExecQuery("SELECT * FROM pricetbl WHERE tedad>0")
    way.Initialize
    If (way.GetString("matnway")=="pricesame") Then
        Log("meeee")
        Dim i As Int=0
            Do While cur.nextrow
            pnlBuilder(i,job,"cardtext"&NumberFormat(cur.GetString("price"),0,0)&"X"&cur.GetInt("tedad"))
            matndb.ExecNonQuery("INSERT INTO matntbl VALUES(null,"&cur.GetInt("id")&","&cur.GetString("price")&","&cur.GetInt("tedad")&",0)")
            top=top+270dip
            i=i+1
        Loop
        SV_MENU.ContentHeight=top+250dip
    
    Else If way.GetString("matnway")=="diff"  Then
        Do While cur.nextrow
            For j=1 To cur.GetInt("tedad")
                Dim idtag As ResultSet
                matndb.ExecNonQuery("INSERT INTO matntbl VALUES(null,"&cur.GetInt("id")&","&cur.GetString("price")&","&j&",0)")
                idtag=matndb.ExecQuery("SELECT * FROM matntbl")
                Dim idfortag As Int
                Do While idtag.nextrow
                idfortag=idtag.GetInt("id")
                Loop
                diff(i,j)=j
                lastpriceid=cur.GetInt("id")
                lasttedad=cur.GetInt("tedad")
                pnlBuilder(idfortag,job,"card"&NumberFormat(cur.GetString("price"),0,0)&j)
                top=top+270dip
                Next
        
        
            priceid(i)=cur.GetInt("id")
            'lastpriceid=cur.GetInt("id")
        Loop
        SV_MENU.ContentHeight=top+50dip
    
    Else If way.GetString("matnway")=="allsame" Then
    Do While(cur.NextRow)
            matndb.ExecNonQuery("INSERT INTO matntbl VALUES(null,"&cur.GetInt("id")&","&cur.GetString("price")&","&cur.GetInt("tedad")&",0)")
    Loop
        pnlBuilder(0,job,"select cards for sth")
        SV_MENU.Panel.Height=280dip
        job.Release
    Else
        Do While(cur.NextRow)
            matndb.ExecNonQuery("INSERT INTO matntbl VALUES(null,"&cur.GetInt("id")&","&cur.GetString("price")&","&cur.GetInt("tedad")&",0)")
        Loop
        pnlBuilder(0,job,"bla bla bla")
        SV_MENU.Panel.Height=280dip
        job.Release
    End If
    Dim a As ResultSet
    a=matndb.ExecQuery("SELECT * FROM matntbl")
    Do While cur.nextrow
'    a.Position=i
        Log("priceid is:"&a.GetInt("priceid")&"  //price is:"&a.GetString("price")&"   //tedad is:"&a.GetInt("tedad")&"  //matn is:"&a.GetString("matn"))
    Loop
End Sub
Sub pnlBuilder(i As Int,job As HttpJob,uptxt As String )
 
    SV_MENU.BringToFront
    PNL_Container.Initialize("")
    PNL_Pretext(i).Initialize("pnlpretxt")
    PNL_EnterText(i).Initialize("pnlentertxt")
    priceselect.Initialize("")
    ET_EnterText(i).Initialize("ET")
    BTN_pnl1(i).Initialize("")
    BTN_pnl2(i).Initialize("")
    LBL_pnl1.Initialize("")
    LBL_pnl2.Initialize("")
    LBL_Limit.Initialize("")
    LBL_Counter(i).Initialize("")
    arrow(i).Initialize("")
    arrow(i).Tag=i
    arrow2(i).Initialize("")
    arrow2(i).Tag=i
    SV_MENU.Panel.AddView(PNL_Container,5%x,top,90%x,250dip)
    PNL_Container.Color=Colors.White
    PNL_Container.AddView(priceselect,0,0,PNL_Container.Width,20dip)
    priceselect.Text=uptxt
    priceselect.Font=Font.CreateNew2("YekanMobileFaNum",14)
    priceselect.TextAlignment=priceselect.ALIGNMENT_CENTER
    priceselect.TextColor=Colors.DarkGray
    PNL_Container.AddView(PNL_Pretext(i),0,priceselect.Height,PNL_Container.Width,50dip)
    PNL_Pretext(i).Tag=i
    PNL_Pretext(i).AddView(arrow(i),20dip,PNL_Pretext(i).Height/2-3dip,20dip,10dip)
    arrow(i).Bitmap=(LoadBitmap(File.DirAssets,"downarrow.png"))
    arrow(i).ContentMode=arrow(i).MODE_FILL
 
    PNL_Container.AddView(PNL_EnterText(i),0,PNL_Pretext(i).Top+PNL_Pretext(i).Height,PNL_Container.Width,PNL_Container.Height-(priceselect.Height+PNL_Pretext(i).Height))
    PNL_EnterText(i).Tag=i
    PNL_Pretext(i).AddView(BTN_pnl1(i),PNL_Container.Width-35dip,15dip,25dip,25dip)
    PNL_EnterText(i).AddView(arrow2(i),20dip,PNL_Pretext(i).Height/2-3dip,20dip,10dip)
    arrow2(i).Bitmap=(LoadBitmap(File.DirAssets,"downarrow.png"))
    arrow2(i).ContentMode=arrow2(i).MODE_FILL
    RotateView(arrow2(i),300,180)
 
    BTN_pnl1(i).bitmap=LoadBitmap(File.DirAssets,"rb_empty.png")
    ''''
    PNL_Pretext(i).AddView(LBL_pnl1,65dip,13dip,PNL_Pretext(i).Width-110dip,30dip)
    LBL_pnl1.Text="bla bla bla"
    LBL_pnl1.Font=Font.CreateNew2("YekanMobileFaNum",12)
    LBL_pnl1.TextAlignment=LBL_pnl1.ALIGNMENT_RIGHT
    LBL_pnl1.TextColor=Colors.Black
        
    PNL_EnterText(i).AddView(BTN_pnl2(i),PNL_Container.Width-35dip,15dip,25dip,25dip)
        
    BTN_pnl2(i).Bitmap=(LoadBitmap(File.DirAssets,"rb_fill.png"))
    ''''
    PNL_EnterText(i).AddView(LBL_pnl2,65dip,13dip,PNL_EnterText(i).Width-110dip,30dip)
    LBL_pnl2.Text="mytxt"
    LBL_pnl2.Font=Font.CreateNew2("YekanMobileFaNum",12)
    LBL_pnl2.TextAlignment=LBL_pnl2.ALIGNMENT_RIGHT
    LBL_pnl2.TextColor=Colors.Black
    ''''
    PNL_EnterText(i).AddView(ET_EnterText(i),15dip,BTN_pnl2(i).Top+BTN_pnl2(i).Height+10dip,PNL_EnterText(i).Width-30dip,100dip)
    ET_EnterText(i).Font=Font.CreateNew2("YekanMobileFaNum",12)
    ET_EnterText(i).TextAlignment=ET_EnterText(i).ALIGNMENT_RIGHT
    ET_EnterText(i).Initialize("ET_EnterText")
 
    ET_EnterText(i).TextColor=Colors.Black
    ET_EnterText(i).HintText="enter text"
    ET_EnterText(i).Color=Colors.Gray
    ET_EnterText(i).Font=Font.CreateNew2("YekanMobileFaNum",14)
    ET_EnterText(i).TextAlignment=ET_EnterText(i).ALIGNMENT_CENTER
    ET_EnterText(i).KeyboardType=ET_EnterText(i).TYPE_DEFAULT
    ET_EnterText(i).RequestFocus
    ET_EnterText(i).Tag=i
 
    '''''
    PNL_EnterText(i).AddView(LBL_Limit,PNL_EnterText(i).Width/2,ET_EnterText(i).Height,(PNL_EnterText(i).Width/2)-20dip,20dip)
    LBL_Limit.TextColor=Colors.Red
    LBL_Limit.TextAlignment=LBL_Limit.ALIGNMENT_RIGHT
    LBL_Limit.Font=Font.CreateNew2("YekanMobileFaNum",10)
    '''''
    PNL_EnterText(i).AddView(LBL_Counter(i),ET_EnterText(i).Left,LBL_Limit.Top,PNL_EnterText(i).Width/2,20dip)
    LBL_Counter(i).TextColor=Colors.Red
    LBL_Counter(i).TextAlignment=LBL_Counter(i).ALIGNMENT_RIGHT
    LBL_Counter(i).Font=Font.CreateNew2("YekanMobileFaNum",10)
 
    'spiner
    spiner(i).Initialize(Me,"spinner")
    PNL_Pretext(i).AddView(spiner(i).GetBase,0,PNL_Pretext(i).Height,PNL_Pretext(i).Width,PNL_Pretext(i).Height)
    spiner(i).GetBase.Color=Colors.RGB(238,238,238)
    spiner(i).TextColor=Colors.DarkGray
    spiner(i).Tag=i
 
    list1.Initialize
    row=Regex.Split("</br>",job.GetString)
    For k=0 To row.Length-1
        field=Regex.Split("~~",row(k))
        list1.Add(field(1))
    Next
 
    spiner(i).AddAll(list1)
    spiner(i).TextAlignment=spiner(i).ALIGNMENT_CENTER
    spiner(i).SelectedIndex=0
    spiner(i).Color=Colors.RGB(238,238,238)
    spiner(i).TextColor=Colors.DarkGray
End Sub
Sub spinner_ItemClick (index As Int, value As Object)
Dim spin As spinner=Sender
    Log("nc(" & spin.Tag & ") was clicked")
    Log("The Value = " & value)
    texts(spin.Tag )=value
End Sub

Sub ET_TextChanged (OldText As String, NewText As String)
   Dim et As TextField=Sender
    log(et.tag)

End Sub
 
Last edited:

Erel

Administrator
Staff member
Licensed User
I don't understand the code.
B4X:
PNL_EnterText(i).AddView(ET_EnterText(i),15dip,BTN_pnl2(i).Top+BTN_pnl2(i).Height+10dip,PNL_EnterText(i).Width-30dip,100dip)
    ET_EnterText(i).Font=Font.CreateNew2("YekanMobileFaNum",12)
    ET_EnterText(i).TextAlignment=ET_EnterText(i).ALIGNMENT_RIGHT
    ET_EnterText(i).Initialize("ET_EnterText")
Why are you initializing the view after you added it???

Why aren't you using the visual designer to create the layout?

In most cases it is better to use xCustomListView instead of ScrollView.
 

mohammadreza hosseinzadeh

Member
Licensed User
I don't understand the code.

Why are you initializing the view after you added it???

Why aren't you using the visual designer to create the layout?

In most cases it is better to use xCustomListView instead of ScrollView.
oh thanks erel its my mistake
its solved now
your right im gonna use xCustomListView next time
 
Top