Skip to content Skip to sidebar Skip to footer

Listview Inside Recyclerview Dont Scroll

i have a list view inside a recyclerview like this: and scrolling of listview doesnt work on this implementation. my goal is when clicking on button the listview toggle to show an

Solution 1:

You should not use a ListView inside another scrollable view. In this case you are using a ListView inside a RecyclerView.

Use a LinearLayout instead of the ListView. Something like:

publicclassMyListLayoutextendsLinearLayoutimplementsView.OnClickListener {

    private Adapter list;
    private View.OnClickListener mListener;

    publicMyListLayout(Context context) {
        super(context);
    }

    publicMyListLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

    }

    publicMyListLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @OverridepublicvoidonClick(View v) {
        if (mListener!=null)
            mListener.onClick(v);
    }

    publicvoidsetList(Adapter list) {
        this.list = list;

        //Popolute listif (this.list!=null){
            for (int i=0;i<this.list.getCount();i++){
                View item= list.getView(i, null,null);
                this.addView(item);
            }
        }

    }

    publicvoidsetmListener(View.OnClickListener mListener) {
        this.mListener = mListener;
    }
}

Post a Comment for "Listview Inside Recyclerview Dont Scroll"