-
Create EditText on button click in Android
over 9 years ago
-
over 5 years ago
Thank you sir for this tutorial, it works perfectly fine
But i'd like to ask,
Is there a way i can add all the children of LinearLayout below the existing contents in a scrollView and they will appear just exactly the way i defined them in my xml
please check out my xml code below
Thank you very much sir
Expecting your kind response
<ScrollView android:id="@+id/scroll" android:layout_width="match_parent" android:layout_height="481dp" android:layout_marginTop="8dp" android:paddingBottom="50dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.481" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView5"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="120dp" android:orientation="vertical" android:paddingBottom="40dp"> <EditText android:id="@+id/Type" android:layout_width="match_parent" android:layout_height="46dp" android:layout_marginStart="16dp" android:layout_marginLeft="16dp" android:layout_marginTop="52dp" android:layout_marginEnd="16dp" android:layout_marginRight="16dp" android:background="@drawable/edittext_bg" android:ems="10" android:hint="Enter type of Item" android:inputType="text" android:paddingStart="20dp" android:paddingLeft="20dp" android:paddingTop="10dp" android:paddingEnd="10dp" android:paddingRight="10dp" android:paddingBottom="10dp" android:textSize="14sp" /> <EditText android:id="@+id/ItemSize" android:layout_width="match_parent" android:layout_height="55dp" android:layout_marginStart="16dp" android:layout_marginLeft="16dp" android:layout_marginTop="24dp" android:layout_marginEnd="16dp" android:layout_marginRight="16dp" android:background="@drawable/edittext_bg" android:ems="10" android:hint="Enter size of Item" android:inputType="numberDecimal" android:paddingStart="20dp" android:paddingLeft="20dp" android:paddingTop="10dp" android:paddingEnd="10dp" android:paddingRight="10dp" android:paddingBottom="10dp" android:textSize="14sp"/> <EditText android:id="@+id/quantity" android:layout_width="match_parent" android:layout_height="55dp" android:layout_marginStart="16dp" android:layout_marginLeft="16dp" android:layout_marginTop="24dp" android:layout_marginEnd="16dp" android:layout_marginRight="16dp" android:background="@drawable/edittext_bg" android:ems="10" android:hint="Enter Quantity of Item" android:inputType="number" android:paddingStart="20dp" android:paddingLeft="20dp" android:paddingTop="10dp" android:paddingEnd="10dp" android:paddingRight="10dp" android:paddingBottom="10dp" android:textSize="14sp"/> <EditText android:id="@+id/priceOfItem" android:layout_width="match_parent" android:layout_height="55dp" android:layout_marginStart="16dp" android:layout_marginLeft="16dp" android:layout_marginTop="24dp" android:layout_marginEnd="16dp" android:layout_marginRight="16dp" android:background="@drawable/edittext_bg" android:ems="10" android:hint="Enter Price of Item" android:inputType="number" android:paddingStart="20dp" android:paddingLeft="20dp" android:paddingTop="10dp" android:paddingEnd="10dp" android:paddingRight="10dp" android:paddingBottom="10dp" android:textSize="14sp"/> <EditText android:id="@+id/discountedAmount" android:layout_width="match_parent" android:layout_height="55dp" android:layout_marginStart="16dp" android:layout_marginLeft="16dp" android:layout_marginTop="24dp" android:layout_marginEnd="16dp" android:layout_marginRight="16dp" android:background="@drawable/edittext_bg" android:ems="10" android:hint="Enter The Discounted Amount" android:inputType="number" android:paddingStart="20dp" android:paddingLeft="20dp" android:paddingTop="10dp" android:paddingEnd="10dp" android:paddingRight="10dp" android:paddingBottom="10dp" android:textSize="14sp"/> <EditText android:id="@+id/transportCost" android:layout_width="match_parent" android:layout_height="55dp" android:layout_marginStart="16dp" android:layout_marginLeft="16dp" android:layout_marginTop="24dp" android:layout_marginEnd="16dp" android:layout_marginRight="16dp" android:background="@drawable/edittext_bg" android:ems="10" android:hint="Enter the transportation cost" android:inputType="number" android:paddingStart="20dp" android:paddingLeft="20dp" android:paddingTop="10dp" android:paddingEnd="10dp" android:paddingRight="10dp" android:paddingBottom="10dp" android:textSize="14sp"/> </LinearLayout> </ScrollView> <Button android:id="@+id/addMore" android:layout_width="176dp" android:layout_height="43dp" android:layout_marginTop="28dp" android:layout_marginBottom="53dp" android:background="@drawable/curved_button" android:onClick="buttonAddMore" android:paddingStart="5dp" android:paddingLeft="2dp" android:paddingEnd="19dp" android:paddingRight="10dp" android:text="@string/Add More Items" android:textAllCaps="false" android:textColor="@android:color/background_light" android:textSize="18sp" android:typeface="serif" app:layout_constraintBottom_toTopOf="@+id/bottom_footer" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/scroll" app:layout_constraintVertical_bias="0.68" /> <Button android:id="@+id/NextButton" android:layout_width="176dp" android:layout_height="43dp" android:layout_marginTop="28dp" android:layout_marginBottom="53dp" android:background="@drawable/clear_field" android:onClick="ProceedToNextPage" android:paddingStart="5dp" android:paddingLeft="2dp" android:paddingEnd="19dp" android:paddingRight="10dp" android:text="@string/Next Button" android:textAllCaps="false" android:textColor="@android:color/background_light" android:textSize="18sp" android:typeface="serif" app:layout_constraintBottom_toTopOf="@+id/bottom_footer" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/scroll" app:layout_constraintVertical_bias="0.68" />
-
-
over 5 years ago
Thanks for this sir, it works perfectly.
But is there a way i can add all the children of LinearLayout below the existing one and they will appear just like the way i defined the default and i can still use all the inputs from both layouts to make calculations
Thank you very much -
-
over 8 years ago
Hi Sir The above code is not working for A Relative Layout What changes should i make to work it there?
-
3 Comment(s)