В представлении добавления списка действий по нажатию кнопки.
В главном представлении сохранения клика мне нужно сохранить все данные списка одновременно.
это мой основной вид, где добавление список
<layout
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:paddingBottom="10dp"
android:background="@color/black"
android:layout_height="match_parent">
<include layout="@layout/toolbar_text" android:id="@+id/mytool"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="10dp"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/layoutRoot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:background="@color/colorPrimary"
android:layout_marginTop="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:layout_marginStart="15dp">
<TextView
android:id="@+id/txtMeal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Protocol is for"/>
<!-- <ImageView
android:id="@+id/ivDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/iv_delete"
android:onClick="onClick"
android:layout_alignParentRight="true" />-->
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="15dp"
android:layout_marginTop="10dp"
android:background="@drawable/edit_gradient"
android:layout_marginEnd="20dp">
<!-- <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:paddingTop="5dp"
android:text="My self"
android:paddingBottom="5dp"
android:paddingStart="15dp"
android:textSize="14sp"
android:layout_centerVertical="true"
android:singleLine="true"
android:textColor="@color/white" />-->
<Spinner
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:id="@+id/spinProtocol"
android:layout_alignParentRight="true">
</Spinner>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start date"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:textColor="@color/white"/>
<RelativeLayout
android:id="@+id/rlStartDate"
android:layout_width="match_parent"
android:onClick="onClick"
android:layout_height="60dp"
android:layout_marginStart="15dp"
android:layout_marginTop="10dp"
android:background="@drawable/edit_gradient"
android:layout_marginEnd="20dp">
<TextView
android:id="@+id/txtStartDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:paddingTop="5dp"
android:text="select date"
android:paddingBottom="5dp"
android:paddingStart="15dp"
android:textSize="14sp"
android:layout_centerVertical="true"
android:singleLine="true"
android:textColor="@color/white" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/calendar"
android:layout_marginEnd="15dp"
android:id="@+id/imgProStartDate"
android:tint="@color/red"
android:layout_centerVertical="true"
android:layout_alignParentRight="true">
</ImageView>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="End date"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:textColor="@color/white"/>
<RelativeLayout
android:id="@+id/rlEndDate"
android:layout_width="match_parent"
android:onClick="onClick"
android:layout_height="60dp"
android:layout_marginStart="15dp"
android:layout_marginTop="10dp"
android:background="@drawable/edit_gradient"
android:layout_marginEnd="20dp">
<TextView
android:id="@+id/txtEndDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:paddingTop="5dp"
android:text="end date"
android:paddingBottom="5dp"
android:paddingStart="15dp"
android:textSize="14sp"
android:layout_centerVertical="true"
android:singleLine="true"
android:textColor="@color/white" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/calendar"
android:layout_marginEnd="15dp"
android:id="@+id/imgProEndDate"
android:tint="@color/red"
android:layout_centerVertical="true"
android:layout_alignParentRight="true">
</ImageView>
</RelativeLayout>
</LinearLayout>
<!--Workout selected lisating -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:background="@color/colorPrimary"
android:layout_marginTop="5dp">
<LinearLayout
android:id="@+id/viewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="10dp">
</LinearLayout>
<Button
android:id="@+id/btnAddMeal"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="15dp"
android:text="ADD MORE WORKOUT"
android:textColor="@color/white"
android:onClick="onClick"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
<!--<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/layout_workout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:background="@color/colorPrimary"
android:layout_marginTop="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Workout Name: 1"
android:id="@+id/workout_name"
android:layout_marginStart="5dp"
android:layout_marginTop="15dp"
android:textColor="@color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="15dp"
android:layout_alignEnd="@+id/workout_name"
android:textColor="@color/white"/>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_edit_white"
android:layout_marginEnd="15dp"
android:id="@+id/ivEdit"
android:layout_marginTop="15dp"/>
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/ic_close"
android:layout_marginEnd="15dp"
android:id="@+id/ivDelelte"
android:layout_marginTop="15dp"
android:tint="@color/white"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/_30sdp"
android:background="@color/red">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_10sdp"
android:text="Excercise"
android:layout_weight="2"
android:layout_gravity="center"
android:textColor="@color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sets"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="@color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reps"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="@color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rest(s)"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="@color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Temp"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="@color/white"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_5sdp"
tools:listitem="@layout/user_workout_list"
android:id="@+id/selected_excercise_list"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+ Add Excercises"
android:id="@+id/add_excercise"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:textColor="@color/red"/>
</LinearLayout>
</LinearLayout>-->
<!--Workout name -->
<!-- <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:background="@color/colorPrimary"
android:layout_marginTop="5dp">
<LinearLayout
android:id="@+id/viewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="10dp">
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/btnAddMeal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:padding="15dp"
android:text="ADD More WORKOUT"
android:drawableStart="@drawable/add"
android:drawablePadding="5dp"
android:layout_centerHorizontal="true"
android:layout_marginStart="15dp"
android:textColor="@color/white"
android:background="@drawable/button_gray_gredient"
android:onClick="onClick"/>
</RelativeLayout>
</LinearLayout>-->
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:layout_marginStart="15dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="15dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight=".50"
android:layout_gravity="center"
android:id="@+id/llDraft"
android:layout_marginEnd="10dp"
android:gravity="center"
android:background="@drawable/rect_border">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SAVE TO DRAFT"
android:fontFamily="@font/rubik_bold"
android:textColor="@color/text_color"
android:layout_gravity="center"
android:gravity="center_horizontal"/>
</LinearLayout>
<LinearLayout
android:id="@+id/llSave"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight=".50"
android:layout_gravity="center"
android:onClick="onClick"
android:gravity="center"
android:layout_marginStart="10dp"
android:background="@drawable/button_red_gredient">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SAVE "
android:fontFamily="@font/rubik_bold"
android:textColor="@color/white"
android:layout_gravity="center"
android:gravity="center_horizontal"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</layout>
И это мой вид списков, который я могу добавить по нажатию кнопки максимум 5 раз, и теперь мне нужно сохранить все данные листинга, которые были добавлены в основной вид, в android.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/layoutRoot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:background="@color/colorPrimary"
android:layout_marginTop="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Workout Name 1"
android:id="@+id/workout_name"
android:layout_marginStart="5dp"
android:layout_marginTop="15dp"
android:textColor="@color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="15dp"
android:layout_alignEnd="@+id/workout_name"
android:textColor="@color/white"/>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_edit_white"
android:layout_marginEnd="15dp"
android:id="@+id/ivEdit"
android:layout_marginTop="15dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/iv_delete"
android:padding="@dimen/_2sdp"
android:layout_marginEnd="15dp"
android:id="@+id/ivDelelte"
android:layout_marginTop="15dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/_30sdp"
android:background="@color/red">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_10sdp"
android:text="Excercise"
android:layout_weight="2"
android:layout_gravity="center"
android:textColor="@color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sets"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="@color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reps"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="@color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rest(s)"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="@color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Temp"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="@color/white"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/excercise_list"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+ Add Excercises"
android:id="@+id/add_program_excercise"
android:clickable="true"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:textColor="@color/red"/>
</LinearLayout>
</LinearLayout>