java - Dynamically made Layout with EditText - Android -


this isn't of question, more of explanation, know whats happening , not treat things black box. i'm making android app, , created form can dynamically make new field add form, , field has 2 edit text next each other.

formlayout.xml

<linearlayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:orientation="horizontal"     android:weightsum="1">  <edittext     android:id="@+id/team_form_player_name"     android:layout_width="0dp"     android:layout_height="wrap_content"     android:layout_marginbottom="10dp"     android:layout_marginright="7dp"     android:layout_weight="1"     android:background="@color/white"     android:hint="@string/form_hint_team_player_name"     android:inputtype="textcapwords"     android:padding="15dp"/>  <edittext     android:id="@+id/team_form_player_number"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_marginbottom="10dp"     android:background="@color/white"     android:hint="@string/form_hint_team_player_number"     android:inputtype="number"     android:padding="15dp"/> </linearlayout> 

and inside button listener when clicked, it'll create new field

 view layout = getlayoutinflater().inflate(r.layout.layout_add_new_field_team, null);  edittext name = (edittext)layout.findviewbyid(r.id.team_form_player_name);  edittext number = (edittext)layout.findviewbyid(r.id.team_form_player_number);  playername.add(name); //arraylist  playernumber.add(number); //arraylist  containerlayout.addview(layout); 

being different layout had inflate view. anyway, question this. how work? code, i'm adding edit text, each time respectful array. im adding same layout each time, im not using "new" not instantiating new. , if create 10 fields @ once, fill in fields. , run method

for(edittext edit : playernumber) {       string test = edit.gettext().tostring();       system.out.println(test); } 

it gives me correct values in each field. how happen? because on add field click, instantly adds edit text array fields empty. , theres no code inputting values array. i'm boggled works , know how does. have idea?

.inflate(layoutresid) == "create new instance of layout"

so every time use inflate creating instances of views in layout, in case linearlayout , 2 edittext views inside it.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -