Change ListView layout to cells layout

197 views Asked by At

I have a ListView in my Android app. The ListView supposed to be a catalog of items. Right now, it doesn't look very much like catalog, since it is shown as rows list.

Is there a way to create some sort of a table view with 3 vertical rows and as many horizontal rows as the items count in the catalog, and still use the same data which I'm using in the ListView? Also, how to change the cell layout to be shown well as a rectangle cell?

CellLayout.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/itemNameList"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/itemPriceList"
    android:layout_below="@+id/itemNameList"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"/>

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/itemImageList"
    android:layout_alignParentTop="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

1

There are 1 answers

0
Ido On

I solved it in a very easy method: I've just changed the type of the ListView to GridView and fixed the cell layout, so it will be shown vertically instead of horizontally.