0

I'm new to Android. On Click of a button I need to add Relative layout, further click the same button I want to attach same relative layout with different values to previous relative layout and so on, it should be done vertically. Later I will be reading values from the layout.

And on click of the clear inside layout, I should be able to remove the added layout as well.

What are the ways to do it?

Layout code,

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="match_parent">

    <EditText
        android:id="@+id/number"
        style="@style/Edit_Text"
        android:enabled="false"
        android:tag="phone_number"
        android:hint="Phone Number"
        android:inputType="phone"
        />
    <TextView
        android:id="@+id/remove"
        android:layout_width="30dip"
        android:layout_height="30dip"
        android:layout_alignParentRight="true"
        android:text="x"
        android:gravity="center"
        android:layout_centerVertical="true"
        android:layout_marginRight="2dip"/>

irigs
  • 51
  • 4
  • 2
    I really do not understand what you want ? – Anders Sørensen Sep 11 '17 at 11:48
  • 2
    I would suggest you use a RecyclerView for this, otherwise your code is going to get messy, fast. https://stackoverflow.com/questions/40584424/simple-android-recyclerview-example – MSpeed Sep 11 '17 at 11:48
  • When you say "attach" you're probably thinking "add to list" ? If this is the case then you should definitely go with RecyclerView. – Gotiasits Sep 11 '17 at 11:49
  • @Anders Kink, Kindly check the attached image, that's how I want. I need to remove the item as well. – irigs Sep 11 '17 at 12:57

0 Answers0