Created
November 13, 2017 15:37
-
-
Save Lzyct/4dae517d5e72ba6871261c995a3b729b to your computer and use it in GitHub Desktop.
Generate TextInputLayout with TextInputEditText
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | |
| */ | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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