I am stuck here at one point where I am using the for loop to display the inflater layout multiple time the inflated layout consists of edit text and the spinner.Here is the main problem I am facing is that when I try to get the entire text in the edit text but getting only the last value edit text data in the array list but I need the All Above text values
Code.java
LinearLayout ll3 = (LinearLayout) findViewById(R.id.ll3);
View view;
LayoutInflater layoutInflater = getLayoutInflater();
for (int i = 1; i <= 4; i++) {
view = layoutInflater.inflate(R.layout.specify_custom_layout, ll3, false);
constantname = (TextView) view.findViewById(R.id.constantname);
constantname.setText("Medicine" + i);
selectionname = (MaterialSpinner) view.findViewById(R.id.selectionname);
ArrayAdapter<String> slectionadapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.specify_text, select);
slectionadapter.setDropDownViewResource(R.layout.spinner_dropdown);
selectionname.setAdapter(slectionadapter);
editText3 = (EditText) view.findViewById(R.id.editText3);
String quantity = editText3.getText().toString();
List<String> data = new ArrayList<String>();
data.add(quantity);
ll3.addView(view);
}
layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ll2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ll">
<TextView
android:id="@+id/constantname"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:text="Medicine"
android:textSize="20dp"
android:textColor="#000"
android:textColorHint="#000" />
<EditText
android:id="@+id/editText3"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/constantname"
android:textColor="#000"
android:inputType="number"
android:textColorHint="#000" />
<fr.ganfra.materialspinner.MaterialSpinner
android:id="@+id/selectionname"
android:layout_width="100dp"
android:layout_height="wrap_content"
app:ms_arrowSize="16dp"
android:layout_toRightOf="@+id/editText3"
app:ms_baseColor="@color/colorPrimary"
app:ms_enableFloatingLabel="false"
app:ms_hint="Med Type"
app:ms_thickness="1dp"
/>
</RelativeLayout>