'Not able to put recycler view as ExpandableListView header layout

I want to display a recycler view inside the ExpandableListView header item.But I am getting an issue my header is not clickable when I put a recycler view in it.

Here is my code:-

header.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">


    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="1"
        android:padding="8dp"
        android:background="@color/grey">

        <TextView
            android:id="@+id/lblListHeader"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:paddingLeft="5dp"
            android:textSize="15dp"
            android:layout_weight=".25"
            android:text="#"
            android:textColor="@color/ModeltitleColor" />
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight=".65"
            >

<android.support.v7.widget.RecyclerView
    android:id="@+id/ivRecyclerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"

    />
        </LinearLayout>


              

                

              

                <ImageView
                    android:id="@+id/iv_group_indicator"
                    android:layout_width="0dp"
                    android:layout_height="30dp"
                    android:layout_gravity="center_vertical"
                    android:layout_weight=".10"
                    android:src="@drawable/ic_arrow_drop_down_black_24dp" />




    </LinearLayout>


</LinearLayout>

here I am setting the group:-

@Override
    public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.zonal_list_group, viewGroup, false);
        }
        TextView textView = view.findViewById(R.id.lblListHeader);
        RecyclerView recyclerView=view.findViewById(R.id.ivRecyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false));

        ZoneNameAdapter zoneNameAdapter =new ZoneNameAdapter(zonalSnapShotResponse.keyFigureDataGroups.get(i).zones,context);
        recyclerView.setAdapter(zoneNameAdapter);
        ImageView imageView = view.findViewById(R.id.iv_group_indicator);
        textView.setText(zonalSnapShotResponse.keyFigureDataGroups.get(i).dataGroup);
        imageView.setImageResource(R.drawable.ic_arrow_drop_down_black_24dp);

        if (b) {
            imageView.setRotation(180f);

        } else {
            imageView.setRotation(0f);
        }


        return view;
    }

getChildItemCount does not get called when I put recycler view in the header.

I have tried multiple solutions but noting worked for me.Please help



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source