How to remove redundancy item in CardView layout
<p>I'm using a CardView Layout in a RecyclerView, JSON will load data and fill the adapter. My layout includes a ImageView, a TextView and everything is fine.</p>

<p>This is the <strong>Adapter</strong> class (<strong>UPDATED</strong>):</p>

<pre><code>public class RecyclerViewAdapter extends RecyclerView.Adapter&lt;RecyclerViewAdapter.ViewHolder&gt; {

    private static final int TYPE_HEADER = 4;
    private static final int TYPE_ITEM = 1;
    Context context;
    List&lt;CarData&gt; getCarData;  // getDataAdapter
    ImageLoader imageThumbLoader;

    public RecyclerViewAdapter(List&lt;CarData&gt; getCarData, Context context){
        super();
        this.getCarData = getCarData;
        this.context = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recyclerview_items, parent, false);
        ViewHolder viewHolder = new ViewHolder(v);

        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder Viewholder, int position) {
        // if (!isPositionHeader(position)) {
            CarData getCarData1 = getCarData.get(position - 1);
            imageThumbLoader = ServerImageParseAdapter.getInstance(context).getImageLoader();

            imageThumbLoader.get(getCarData1.getImageThumb(),
                    ImageLoader.getImageListener(
                            Viewholder.imageThumb,//Server Image
                            R.mipmap.ic_launcher,//Before loading server image the default showing image.
                            android.R.drawable.ic_dialog_alert //Error image if requested image dose not found on server.
                    )
            );

        Viewholder.imageThumb.setImageUrl(getCarData1.getImageThumb(), imageThumbLoader);
        Viewholder.titleName.setText(getCarData1.getTitleName());
        Viewholder.doorName.setText(Html.fromHtml("&lt;b&gt;Số cửa:&lt;/b&gt; " + getCarData1.getDoorName()));
        Viewholder.seatName.setText(Html.fromHtml("&lt;b&gt;Số ghế:&lt;/b&gt; " + getCarData1.getSeatName()));
        Viewholder.cityName.setText(Html.fromHtml(getCarData1.getCityName()));
        Viewholder.districtName.setText(Html.fromHtml(getCarData1.getDistrictName()));

        // }
    }

    public int getDataAdapter() {
        return getCarData == null ? 0 : getCarData.size();
    }

    @Override
    public int getItemViewType(int position) {
        if (isPositionHeader(position)) {
            return TYPE_HEADER;
        }

        return TYPE_ITEM;
    }

    @Override
    public int getItemCount() {

        return getDataAdapter();  // + 1
    }

    private boolean isPositionHeader(int position) {
        return position == 0;
    }

    class ViewHolder extends RecyclerView.ViewHolder{

        public TextView titleName;
        public NetworkImageView imageThumb;
        public TextView doorName;
        public TextView seatName;
        public TextView cityName;
        public TextView districtName;

        public ViewHolder(View itemView) {

            super(itemView);

            titleName = (TextView) itemView.findViewById(R.id.titleName);
            imageThumb = (NetworkImageView) itemView.findViewById(R.id.imageThumb);
            doorName = (TextView) itemView.findViewById(R.id.doorName);
            seatName = (TextView) itemView.findViewById(R.id.seatName);
            cityName = (TextView) itemView.findViewById(R.id.cityName);
            districtName = (TextView) itemView.findViewById(R.id.districtName);
        }
    }

}
</code></pre>

<p>My <strong>layout</strong>:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardview1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="3dp"
card_view:contentPadding="3dp"
card_view:cardCornerRadius="3dp"
card_view:cardMaxElevation="3dp"
card_view:cardUseCompatPadding="true"&gt;

&lt;LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"&gt;

    &lt;com.android.volley.toolbox.NetworkImageView
        android:id="@+id/imageThumb"
        android:layout_width="400dp"
        android:layout_height="230dp"
        android:src="@mipmap/ic_launcher"
        android:gravity="top"
        android:scaleType="centerCrop"/&gt;

    &lt;TextView
        android:id="@+id/titleName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Image View"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@+id/imageThumb"
        android:layout_toEndOf="@+id/imageThumb"
        android:layout_marginLeft="20dp"/&gt;

        &lt;LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="2"&gt;

            &lt;TextView
                android:id="@+id/doorName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="20dp"/&gt;
            &lt;TextView
                android:id="@+id/seatName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="20dp"/&gt;
        &lt;/LinearLayout&gt;

        &lt;LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="2"&gt;

            &lt;TextView
                android:id="@+id/cityName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="20dp"/&gt;

            &lt;TextView
                android:id="@+id/districtName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="20dp"/&gt;

        &lt;/LinearLayout&gt;

    &lt;TextView
        android:id="@+id/checkStatus"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="KIỂM TRA TÌNH TRẠNG XE"
        android:textColor="@color/color_primary_green_dark"
        android:textStyle="bold"
        android:textSize="12dp"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@+id/textView_item32"
        android:layout_toEndOf="@+id/textView_item32"
        android:layout_marginLeft="20dp"/&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p></p>

<p>But when I load data for the first time, there is a redundant item. Look at the following attachment:</p>

<p><a href="https://i.stack.imgur.com/0NbxN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0NbxN.png" alt="enter image description here"></a></p>

<p>The exception has happened when updated code:</p>

<pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
              Process: pl.michalz.hideonscrollexample, PID: 9794
              java.lang.ArrayIndexOutOfBoundsException: length=18; index=-1
                  at java.util.ArrayList.get(ArrayList.java:310)
                  at pl.michalz.hideonscrollexample.RecyclerViewAdapter$override.onBindViewHolder(RecyclerViewAdapter.java:54)
                  at pl.michalz.hideonscrollexample.RecyclerViewAdapter$override.access$dispatch(RecyclerViewAdapter.java)
                  at pl.michalz.hideonscrollexample.RecyclerViewAdapter.onBindViewHolder(RecyclerViewAdapter.java:0)
                  at pl.michalz.hideonscrollexample.RecyclerViewAdapter.onBindViewHolder(RecyclerViewAdapter.java:20)
                  at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5768)
                  at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5801)
</code></pre>

<p>How do I remove this redundant item in the CardView?</p>