Skip to content

Instantly share code, notes, and snippets.

@Lzyct
Created November 13, 2017 15:37
Show Gist options
  • Select an option

  • Save Lzyct/4dae517d5e72ba6871261c995a3b729b to your computer and use it in GitHub Desktop.

Select an option

Save Lzyct/4dae517d5e72ba6871261c995a3b729b to your computer and use it in GitHub Desktop.
Generate TextInputLayout with TextInputEditText
private fun generateTextInputLayout(count: Int) {
ll_root.removeAllViews() // remove prevous TextInputEditText on root layout
for (item in 1..count) {
//create textInputLayout
val textInputLayout = TextInputLayout(this)
ll_root.addView(textInputLayout) // add View TextInputLayout in LinearLayout
//create textInputEditText
val textInputEditText = TextInputEditText(this)
textInputEditText.hint = "TextInputEditText$count"
textInputEditText.id = item
textInputLayout.addView(textInputEditText) //add View TextInputEditText in TextInputLayout
/*
<LinearLayout>
// Create layout from your count loop
<TextInputLayout>
<TextInputEditText/>
</TextInputLayout>
//
</LinearLayout>
*/
}
}
<LinearLayout
android:width="match_parent"
android:height="match_parent"
android:orientation="vertical"
android:id="@+id/ll_root"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment