How to make a Relative Layout Duplicate Itself Inside a Linear Layout On Button Click



I have an alert dialogue set up inside a RelativeLayout. A small section is a ListView with a RelativeLayout inside. My xml file is as follows:



<ScrollView xmlns:android="http://ift.tt/nIICcg">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">

...

<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/bar_main"
android:id="@+id/dialoguelistview"
android:padding="10dp">
<RelativeLayout>
<EditText
android:id="@+id/Item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:hint="@string/Item"
/>

<EditText
android:id="@+id/Quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_alignParentLeft="true"
android:hint="@string/Quantity"
android:layout_below="@id/Item"/>

<EditText
android:id="@+id/Cost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_toRightOf="@id/Quantity"
android:hint="@string/Cost"
android:layout_below="@id/Item"/>

<Button
android:id="@+id/Button01"
android:layout_width="30dip"
android:layout_height="30dip"
android:layout_alignParentRight="true"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
android:layout_below="@id/Item"
android:background="@drawable/round_button"
android:text="@string/another_item"
android:textColor="#fff"
android:onClick = "addAnotherItem"></Button>

</RelativeLayout>
</ListView>

...

</RelativeLayout>
</ScrollView>


When the button is clicked, I need the inner relative layout to duplicate itself inside the list view. How can I do this? Thanks in advance!


No comments:

Post a Comment