Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ajpinedam/0be018915e3fd837d54d82c8da61f88f to your computer and use it in GitHub Desktop.
Save ajpinedam/0be018915e3fd837d54d82c8da61f88f to your computer and use it in GitHub Desktop.
Button addTextBoxButton;
LinearLayout textBoxHolder;
List<EditText> _myEditTexts;
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
addTextBoxButton = FindViewById<Button> (Resource.Id.addTextBoxButton);
textBoxHolder = FindViewById<LinearLayout> (Resource.Id.textBoxLayoutHolder);
addTextBoxButton.Click += AddTextBoxButton_Click;
_myEditTexts = new List<EditText> ();
}
void AddTextBoxButton_Click (object sender, System.EventArgs e)
{
var indice = _myEditTexts.Count + 1;
var editText = new EditText (this);
editText.Tag = $"una-forma-de-luego-identificarlos-{indice}";
var layoutParams = new LinearLayout.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
layoutParams.BottomMargin = 6;
editText.LayoutParameters = layoutParams;
editText.Hint = $"Introduzca Texto # {indice}";
//Solo si quieres guardar referencia de ellos para luego tomar su valor.
_myEditTexts.Add (editText);
textBoxHolder.AddView (editText);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment