Search code examples
javaandroiduser-interfacelistviewtablelayout

Differences between purpose of ListView and TableView


I've something like 10-30 object and every object have some datas(about 10) like , age, birthday and ...

I want to show all of them in a list , but I don't know TableLayout is made for what I want to do or ListView ? What are differences between them and pros and cons?


Solution

  • If your list items are fixed and limited then you can simply use TableLayout and ScrollView (to scroll in small devices). For this you need to do extra work programmatically. But ListView is a view which groups several similar items and display them in vertical scrollable list. The list items are automatically inserted to the list using an adapter(BaseAdapter). Less strain when compared in development wise as well as it will improve the performance by using already created Views (with ViewHolder design pattern)

    EDIT :

    As you said there is much data in one item. So first of all

    • draw on paper how each item should display.
    • then create a layout xml file. use best fit Layout (RelativeLayout mostly)
    • assign the id's for each View .
    • inflate the layout in getView method of your BaseAdapter subclass.

    for guide you can refer this