I am using an array to implement this. To add, I'm pushing a view in the array and updating the array state. But I'm not sure how to delete it, array.pop() is not working. And even it it does, it would only remove the last element of the array. I want to use something like splice(), where i can pass an index, to delete the view whose "delete" button was invoked. But not sure how to implement this. Any suggestions? I'm adding the code for my add and delete methods. I wanna delete the view whose delete button was pressed. Please help!

[![
](https://i.stack.imgur.com/H4nGA.png)](https://i.stack.imgur.com/H4nGA.png)

[![enter image description here](https://i.stack.imgur.com/nR5MT.png)](https://i.stack.imgur.com/nR5MT.png)

[![enter image description here](https://i.stack.imgur.com/XzfUJ.png)](https://i.stack.imgur.com/XzfUJ.png)

Thanks in advance