It'd be easier if you would post your code too. I tried to code
something up and I saw a list, but there was a lot wrong with it as
compared with what you are trying to show in your layout.

First, I'm not sure what having children views of a ListView in your
layout really means in Android. I don't think that's really the way it
should be done. Really, when you set up your adapter, you have to pass
in the id of a layout that contains what one item in the list looks
like. What that probably means is that you should remove all this xml
you have as a child of the ListView and put it in its own layout, then
reference that when setting up the adapter. I think List7 and List8
api demos should make this clear. Note they don't have children in the
xml.

Second, you have some fill_parent stuff going on that pushes
everything else out of the screen.

On Apr 13, 9:09 am, 6real <[EMAIL PROTECTED]> wrote:
> Delirio,
>
> thanks for your answer.
>
> Actually I tested you sample and it throws a null pointer excetion (??
> I don't know why ??)
>
> I changed also my code in order to use your idea and I have another
> error :
> java.lang.illegalStateException:
> addView(View, LayoutParams) is not supported in AdapterView
>
> The exception is throws as soon as I call the method :
> setContentView(R.layout.main);
>
> here is my code (main.xml), maybe someone could help me with this
> trouble.
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>         android:orientation="vertical" android:layout_width="fill_parent"
>         android:layout_height="fill_parent">
>
>         <TextView android:layout_width="fill_parent"
>                 android:layout_height="wrap_content"
>                 android:text="Hello" />
>
>         <TextView android:id="@+id/last_update"
>                 android:layout_width="fill_parent"
>                 android:layout_height="wrap_content" android:text="07:55:55"
>                 android:padding="5dip" />
>
>         <ListView android:id="@android:id/list"
>                 android:layout_width="fill_parent"
>          android:layout_height="fill_parent">
>
>                 <LinearLayout android:id="@+id/list_item"
>                         android:layout_width="fill_parent"
>                         android:layout_height="fill_parent" 
> android:orientation="vertical">
>
>                         <TextView android:id="@+id/itemNameLbl"
>                                 android:layout_width="fill_parent"
>                                 android:layout_height="wrap_content"
>                                 android:text="My item" android:padding="5dip" 
> />
>
>                         <LinearLayout android:orientation="horizontal"
>                                 android:layout_width="wrap_content"
>                                 android:layout_height="wrap_content"
>                                 android:layout_gravity="center">
>
>                                 <TextView android:id="@+id/freeLbl"
>                                         android:layout_width="fill_parent"
>                                         android:layout_height="wrap_content"
>                                         android:text="@string/si_free_slots"
>                                         android:layout_marginLeft="10dip" 
> android:padding="3dip" />
>
>                                 <TextView android:id="@+id/freeVal"
>                                         android:layout_width="fill_parent"
>                                         android:layout_height="wrap_content" 
> android:padding="3dip"
>                                         android:layout_marginLeft="10dip" 
> android:text="15" />
>
>                                 <TextView android:id="@+id/availableLbl"
>                                         android:layout_width="fill_parent"
>                                         android:layout_height="wrap_content" 
> android:padding="3dip"
>                                         android:text="@string/si_available"
>                                         android:layout_marginLeft="10dip" />
>                                 <TextView android:id="@+id/availableVal"
>                                         android:layout_width="fill_parent"
>                                         android:layout_height="wrap_content" 
> android:padding="3dip"
>                                         android:text="12" 
> android:layout_marginLeft="15dip" />
>                         </LinearLayout>
>
>                         <View android:padding="5dip" 
> android:layout_height="2dip"
>                                 android:background="#FF909090" 
> android:layout_width="fill_parent" /
>
>                 </LinearLayout>
>         </ListView>
>
>         <!--  <LinearLayout
>                 android:id="@+id/main_lst_item_layout"
>                 android:orientation="horizontal"
>                 android:layout_width="fill_parent"
>                 android:layout_height="fill_parent"/>-->
>
>         <Button android:id="@+id/main_add_item_btn"
>                 android:layout_width="fill_parent"
>                 android:layout_height="wrap_content"
>                 android:text="@string/main_add_a_item" />
>
>         <Button android:id="@+id/main_delete_item_btn"
>                 android:layout_width="fill_parent"
>                 android:layout_height="wrap_content"
>                 android:text="@string/main_del_a_item" />
>
>         <Button android:id="@+id/main_edit_item_btn"
>                 android:layout_width="fill_parent"
>                 android:layout_height="wrap_content"
>                 android:text="@string/main_edit_a_item" />
>         <!--         </LinearLayout> -->
> </LinearLayout>
>
> On Apr 11, 5:58 pm, Delirio <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > Maybe you just need to include the following to yourlayoutfile:
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <LinearLayout
> > android:layout_width="fill_parent"
> > android:layout_height="fill_parent"
> > xmlns:android="http://schemas.android.com/apk/res/android";
> > android:orientation="vertical"
>
> > <TextView
> > android:id="@+id/android_server_text"
> > android:layout_width="fill_parent"
> > android:layout_height="wrap_content"
> > android:text="MY LIST TITLE IN A TEXTVIEW"
>
> > </TextView>
> > <ListView
> > android:id="@android:id/list"
> > android:layout_width="wrap_content"
> > android:layout_height="wrap_content"
> > android:padding="5px"
>
> > </ListView>
> > <Button
> > android:id="@+id/btn1"
> > android:layout_width="wrap_content"
> > android:layout_height="wrap_content"
> > android:text="btn1"
> > />
> > </LinearLayout>
>
> > Or if you want to customize the Adapter:
>
> >http://code.google.com/android/samples/ApiDemos/src/com/google/androi...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to