• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps list with multiple items in one row

sionut

Lurker
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
 
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:
<?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
 
Back
Top Bottom