Custom ListView

0

I'm trying to make a Custom ListView. I have my XLM

<ListView
    android:id="@+id/listViewCliente"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:scrollbars="horizontal"
    tools:listitem="@layout/row_cliente"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

Notice that there I put a tools: and pointed to another XML to get the custom style.

In the design tab it shows the correct listview already custom. But when I install it on my phone or emulator it shows the default list.

Has anyone ever gone through this? I've tried uninstalling and installing again, but nothing.

    
asked by anonymous 25.04.2017 / 02:37

1 answer

1

To use a custom layout in the ListView, you have to define a layout XML file representing a row in the ListView and write a custom Adapter to your list that will tell you how to put each data in that XML view. Finally, in MainActivity, you will create an Array of Objects with the data you want to display in the ListView and associate that Adapter with the ListView passing as parameters to it the Array and XML id.

One example: link

    
25.04.2017 / 12:32