Android Question Remove dynamically created view

Sreenadh OG

Member
Licensed User
Hi All,
I want to remove dynamically created views on Button_click event, I am adding two EditText and one button for each BtnAdd_Click(Edit texts for name and phone No., BtnRemove for remove these EditText ).
Now i want to delete corresponding EditTexts and Button on BtnRemove_Click. How can i perform this action on BtnRemove_Click..

removeView.JPG

B4X:
Sub BtnAdd_Click
    etxtName.Initialize("etxtName")
    etxtPhon.Initialize("etxtPhon")
    btnRmv.Initialize("btnRmv")
    etxtName.TextSize=14
    etxtPhon.TextSize=14
    etxtName.Hint="Name"
    etxtPhon.Hint="Phone"
         SVNewCase.Panel.AddView(etxtName,10,(ItemSizeScroll*i),100,ItemSizeScroll/1.3)
        SVNewCase.Panel.AddView(etxtPhon,80,(ItemSizeScroll*i),100,ItemSizeScroll/1.3)
        SVNewCase.Panel.AddView(btnRmv,180,(ItemSizeScroll*i),40,ItemSizeScroll/1.3)
        SVNewCase.Panel.AddView(BtnSubmit,100,ItemSizeScroll*(i+1),60,ItemSizeScroll/1.3)
        editlist.add(etxtName)
          i=i+1
End Sub
'btnRmv is the button created by dynamically
Sub btnRmv_Click
  'Activity.RemoveViewAt() here i want remove corresponding  edittexts           
End Sub
 

DonManfred

Expert
Licensed User
How can i set index for each views?
The views automatically get an index. It´s the <index>'s child view of the panel
The first child has index 0, the second 1 and so on

look at
B4X:
    For Each v As View In SVNewCase.Panel.GetAllViewsRecursive
        ' Search the right view
    Next
 

Sreenadh OG

Member
Licensed User
Thank you..
But I want to remove views in same row of the remove button. So i want get the index of remove button, Now i am using this code..
B4X:
'I am creating more than four buttons
'btnRmv.Initialize("btnRmv")
Sub btnRmv_Click
Dim n As Int
'this code didn't remove particular view
'here i want the index of btnRmv
SVNewCase.Panel.RemoveViewAt(i)
SVNewCase.Panel.RemoveViewAt(i-1)
SVNewCase.Panel.RemoveViewAt(i-2)
End Sub
 
Last edited:
Top