1. Download the #1 Android News App:   EarlyBird - News for Android
    Dismiss Notice

list with multiple items in one row

Last Updated:

  1. sionut

    sionut New Member


    I am trying to figure out how to create a List that contains multiple items on one row. What I want is to have a ListActivity and put multiple buttons on the same row (at least 2), depending on the space available on the device's screen. The user should be able to click/select any of the items in one row.

    I need a list because I will get the data from the database through a Cursor (I will implement a CursorAdapter for that, accessing my local SQLite db)

    All the examples that I've seen so far have only one item per row, so if anybody can give me such an example/explain what's needed, I would be grateful.

    Thank you,

  2. RazzleFnDazzle

    RazzleFnDazzle Well-Known Member

    I'm not sure if this is the best way, but this is how I would do it off the top of my head (I'm also not hugely familiar with all of android). You can create a separate layout for your components

    Code (Text):
    2. <?xml version="1.0" encoding="utf-8"?>
    3. <LinearLayout android:orientation="horizontal">
    4.  <Button android:id="@+id/one"/>
    5. <Button android:id="@+id/two"/>
    6. </LinearLayout>
    Then in your main layout create a ListView called list. Then create your own custom adapter such as an ArrayAdapter that takes R.id.list as its resource and then on getView fill in the listeners with the buttons and/or text

Share This Page