CarinaMj
CarinaMj

Reputation: 197

Is there any possible way to make this custom list?

Is there any possible way to do the android custom listview like in the image below? Custom adapter should have another listview as below.enter image description here

Thanks in advance.

Upvotes: -3

Views: 69

Answers (2)

ali hassoun
ali hassoun

Reputation: 161

activity_main.xml

<LinearLayout
    android:id = "@+id/relativeLayout1"
    android:layout_width = "fill_parent"
    android:layout_height = "wrap_content" >

    <TextView
        android:layout_width = "0dp"
        android:layout_height = "wrap_content"
        android:layout_weight = "2"
        android:gravity = "center"
        android:padding = "5dp"
        android:text = "Firt column title"
        android:textColor = "#ffffff"/ >

    <TextView
        android:layout_width = "0dp"
        android:layout_height = "wrap_content"
        android:layout_weight = "1.5"
        android:gravity = "center"
        android:padding = "5dp"
        android:text = "Second column title"
        android:textColor = "#ffffff" />

    <TextView
        android:layout_width = "0dp"
        android:layout_height = "wrap_content"
        android:layout_weight = "1"
        android:gravity = "center"
        android:padding = "5dp"
        android:text = "third column title"
        android:textColor = "#ffffff" />
</LinearLayout>

<ListView
    android:id = "@+id/listview"
    android:layout_width = "match_parent"
    android:layout_height = "wrap_content"
    android:divider = "@null"/>

cell_shape.xml

<layer-list xmlns:android = "http://schemas.android.com/apk/res/android">

<item
    android:left = "-2dp"
    android:top = "-2dp">
    <shape android:shape = "rectangle" >
        <solid android:color = "@android:color/transparent" />

        <stroke
            android:width = "1dp"
            android:color = "@color/colorCell" />
    </shape>
</item>

listview_row.xml

<LinearLayout
    android:id = "@+id/relativeLayout1"
    android:layout_width = "fill_parent"
    android:layout_height = "wrap_content"
    android:background = "@color/colorCell" >

    <TextView       
        android:id = "@+id/sNo"      
        android:layout_width = "0dp"
        android:layout_height = "match_parent"
        android:layout_weight = "1"
        android:background = "@drawable/cell_shape"
        android:ellipsize = "end"
        android:padding = "5dp"
        android:text = "categorie"
        android:singleLine = "true" />

<ListView
    android:id = "@+id/listview_first section list"
    android:layout_width = "match_parent"
    android:layout_height = "wrap_content"
    android:divider = "@null"/>
<ListView
    android:id = "@+id/listview_number_section_list"
    android:layout_width = "match_parent"
    android:layout_height = "wrap_content"
    android:divider = "@null"/>


</LinearLayout>

Upvotes: 0

Geryson
Geryson

Reputation: 719

As I can see, the rows of the above illustration is not equally sized. It is possible to create it yourself if your plan is to dinamically build up the list item, but maybe it would be a relatively big task ("re-inventing the wheel", if you know what I mean). Here you can find a SO topic about what you should consider when you have to choose between ListView or TableLayout, which can be another solution:

ListView or TableLayout?

In my humble opinion: because what we can see on your image is a table and not a list, it should be made with TableLayout.

If it is your opinion too, here is the official tutorial guide for TableLayout... ;)

https://developer.android.com/guide/topics/ui/layout/grid.html

Upvotes: 0

Related Questions