grouping section within itself in android list view

Viewed 38

I want to show a list as partitions in android. I have an adapter class for this and the getView() method return the cell in the section

fun getView(
    section: Int,
    position: Int,
    convertView: View?,
    parent: ViewGroup?
): View {
    var cellView = convertView
    if (cellView == null) {
        cellView = LayoutInflater.from(context).inflate(R.layout.my_cell_layout, parent, false)

        //same operation
    }
    
    //same operation
    
    return cellView
}

my_cell_layout is below (CellLayout is a custom view)

<CellLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical">

        <LinearLayout
            android:orientation="vertical">

            //same code

        </LinearLayout>
</CellLayout>

This way I can separate the whole list and partitions. But I want to group the items to be displayed for each section within itself. The sample picture is as below.

sample image

I don't know how to do this. I tried wrapping CellLayoutu and the views inside it with cardView, but I got an output like the one below.

wrong result

0 Answers
Related