First of all, thank you for your answers and sorry for the delay. I've
run a lot of tests.

The best solution I found for now is to put each list view inside a
LinearLayout and specified width on it. This works to display list
views side by side. Unfortunately I've noticed that if I ask the list
to fill its parent, the layout don't display as I expect. It seems
that ListView bypass the width parameter of the parent.

As I can't ask the list to fill its parent, items I put inside the
list don't fill the list horizontally. I also tried to change width on
the layout used by each item inside the list but it doesn't work too.
So I'm now stuck on this. Here is my current layout :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
                android:orientation="vertical"
                android:layout_height="fill_parent"
                android:layout_width="wrap_content"
                android:layout_weight="0.3">

                <TextView
                        android:text="List1"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content" />

                <ListView
                        android:id="@+id/list_1"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content" /> <!-- I would 
like to use
this : android:layout_width="fill_parent" -->

                <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
                        android:orientation="horizontal"
                        android:layout_height="fill_parent"
                        android:layout_width="wrap_content">
                        <Button
                                android:text="Add"
                                android:id="@+id/add_list_1"
                                android:layout_height="wrap_content"
                                android:layout_width="wrap_content" />

                        <Button
                                android:text="Delete"
                                android:id="@+id/delete_list_1"
                                android:layout_height="wrap_content"
                                android:layout_width="wrap_content" />
                </LinearLayout>

        </LinearLayout>

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
                android:orientation="vertical"
                android:layout_height="fill_parent"
                android:layout_width="wrap_content"
                android:layout_weight="0.3">

                <TextView
                        android:text="List2"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content" />

                <ListView
                        android:id="@+id/list_2"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content" /> <!-- same here 
-->
        </LinearLayout>

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
                android:orientation="vertical"
                android:layout_height="fill_parent"
                android:layout_width="wrap_content"
                android:layout_weight="0.3">

                <TextView
                        android:text="List3"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content" />

                <ListView
                        android:id="@+id/list_3"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content" /> <!-- here also 
-->
        </LinearLayout>

</LinearLayout>


On the other hand, I've tried to use a TableLayout. It works but it's
not easy to manage other components around the list.

In fact, I struggle with Android layouts. I don't understand how it
can be so difficult to do a so simple design. The fact is whatever
parameter I use, it never displays as I like it to be. Perhaps my
mistake is I tend to use too deep layout as you often do in HTML.

Anyway, I'll keep this topic updated for those who are interested.

Mat.

On Nov 4, 1:48 am, intbt <[email protected]> wrote:
> You can set the layout_width in the xml file to x pixels to control
> the width, use a TableLayout to add adjacent listviews, but it is a
> small screen so it gets crowded in  a hurry.
>
>                 <ListView
>                         android:id="@+id/listvw01"
>                         android:layout_width="45px"
>                         android:layout_height="250px"
>                         android:typeface="serif"
>                         android:textSize="32px"
>                         android:paddingLeft="10px"
>                         android:paddingRight="20px"
>                         android:layout_marginTop="38px"
>                         android:divider="#FFCC00"
>                         />
>
> intbt
>
> On Nov 3, 1:47 pm, Kostya Vasilyev <[email protected]> wrote:
>
>
>
>
>
>
>
> > Mat,
>
> > Not sure what kind of "content" a ListView uses for "wrap_content" width
> > - maybe that's the root of this problem.
>
> > Perhaps you can try, as a test, specifying fixed width for each of the
> > list views, using "dp" units.
>
> > If that works, take a look at layout_weight to automatically resize each
> > list to 1/3 of the available width.
>
> > -- Kostya
>
> > 03.11.2010 2:06, Mat пишет:
>
> > > Hi,
>
> > > I'm looking for a way to put three ListViews side by side.
> > > Documentation specify that ListView "displays a scrolling single
> > > column list". As I'm a bit stubborn, I've done some tests but I only
> > > manage to display one ListView which fill all the screen even if I use
> > > "wrap_content" or if I put each ListView in a LinearLayout.
>
> > > The final goal is to connect these ListViews together, clicking on an
> > > item from the first will update the content of the second, and so on.
>
> > > Should I user ScrollView instead ? For those who will say that three
> > > ListViews won't fit in a mobile screen, I trying to make an
> > > application for a tablet :)
>
> > > Thanks in advance.
>
> > --
> > Kostya Vasilyev -- WiFi Manager + pretty widget 
> > --http://kmansoft.wordpress.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to