I am getting football team lineup data from mySQL database.
I want to show Goalkeepers,Defender,Midfielders as headers on each row with the players data on the recycler.
What should i do?:
1-Create 3 recyclerview?
2-Create 3 custom layouts?
3-Different viewholders?
What i did is this :
What i want to do is : Doing same thing but showing the other data as Defenders with their players and Midfielders with their players
This is my custom layout(recycler_lineup):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:card_view="http://schemas.android.com/tools"
android:orientation="horizontal">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardUseCompatPadding="true"
>
<RelativeLayout
android:layoutDirection="ltr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/txt_competition"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:layout_gravity="end"
android:textStyle="bold"
android:textSize="14sp"
/>
<View
android:id="@+id/view_1"
android:layout_below="@+id/txt_competition"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginTop="3dp"
android:background="?android:attr/listDivider" />
<TextView
android:textAlignment="center"
android:layout_gravity="start"
android:id="@+id/txt_id_player"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/view_1"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="8dp"
android:textColor="#666666"
android:text="1"
android:textSize="16sp" />
<ImageView
android:id="@+id/image_player"
android:layout_width="35dp"
android:layout_height="45dp"
android:layout_marginRight="15dp"
android:layout_marginEnd="15dp"
android:layout_marginTop="5dp"
android:layout_below="@+id/view_1"
android:layout_toStartOf="@+id/txt_id_player"
android:layout_toLeftOf="@+id/txt_id_player"
/>
<TextView
android:textAlignment="center"
android:layout_gravity="start"
android:id="@+id/txt_name_player"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#666666"
android:text="Mahdi H"
android:textSize="13sp"
android:textStyle="bold"
android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"
android:layout_marginTop="5dp"
android:layout_below="@+id/view_1"
android:layout_toLeftOf="@+id/image_player"
android:layout_toStartOf="@+id/image_player" />
<ImageView
android:id="@+id/image_flag_player"
android:layout_width="20dp"
android:layout_height="15dp"
android:background="@drawable/testing"
android:layout_below="@+id/txt_name_player"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:scaleType="fitXY"
android:layout_toLeftOf="@+id/image_player"
android:layout_toStartOf="@+id/image_player" />
<TextView
android:textAlignment="center"
android:layout_gravity="center"
android:id="@+id/txt_nationality_player"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#666666"
android:text="Ahed"
android:textSize="14sp"
android:layout_alignBaseline="@+id/txt_id_player"
android:layout_alignBottom="@+id/txt_id_player"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</ScrollView>
</LinearLayout>
Layout containing the recyclerview:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_post"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
UPDATED : I want to show as this one :