1. 2015 is going to be a great year for Android! Why wait??
    Samsung Galaxy Note 5 | Samsung Galaxy S6 | HTC One M9
  2. New Forum Created: Samsung Gear VR!

list with multiple items in one row


  1. sionut

    sionut New Member

    Hi,

    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,
    Ionut

    Advertisement
    :
  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

    buttons.xml
    Code (Text):

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout android:orientation="horizontal">
     <Button android:id="@+id/one"/>
    <Button android:id="@+id/two"/>
    </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
Loading...

Share This Page