I want to dynamically add editText elements to my layout on button click(say +). Just like the way they get added when adding a new contact in default android contacts. I also want to retrieve the content of each editText into an array or something similar.
How can i achieve this? Please help.
Alright, here’s how to do it.
Create a layout .xml file with the specifications of your desired EditText
in your activity’s code, instantiate a LayoutInflater, you can use LayoutInflater.from(Context)
use the inflater to create and return your EditText View, store it as you want. The layoutInflater will ask for an .xml file.
Add the inflated view to a viewcontainer to have it display wherever.
Good luck