views:

49

answers:

2

My scenario is like this:

<ScrollView     
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"      
   android:scrollbars="vertical"        
   android:background="#ffffeb">

   <LinearLayout 
      android:orientation="vertical"
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"
      android:padding="10dp">

      // Other stuff in between here..

      <LinearLayout
         android:orientation="vertical"   
         android:layout_width="fill_parent"   
         android:layout_height="fill_parent"   
         android:paddingLeft="12dp"   
         android:paddingRight="12dp">

         <Button 
            android:id="@+id/insert_ad_ad_information_category_and_type_button"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dp"
            android:text="@string/insert_ad_ad_information_category_and_type_button"/>

         <ListView
            android:id="@+id/insert_ad_ad_information_parameters_frame"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#ffffeb"
            android:cacheColorHint="#00000000"
            android:divider="#00000000"
            android:dividerHeight="0dp"
            android:scrollbars="none"
            android:listSelector="@android:color/transparent"/>

The problem I have is that I can't get my ListView to get the right height that I want. I'll add a couple of components with my custom BaseAdapter class and everything there works as intended. But when i then debug my application i can only see 1,5 out of 3 components in the list and the rest is hidden futher down in the ListView. But how can i make my ListView calculate how many components i have and get it to show all my components direcly without having too scroll down.

Another thought is if i could populate any other kind of View with my BaseAdapter? Because the only reason I'am using ListView is because of the setAdapter() method.

Appreciate all thoughts and comments :)

A: 

You cannot have a ListView in a ScrollView. Thats where the issue is.

Sameer Segal
Ok, thanks. Any recommendations of how i could solve my problem? Could i add BaseAdapter to another type of View?
David Olsson
Sameer Segal
Great. It works like a charm! :D Thanks again.
David Olsson
A: 

As has been said you can't use ListView inside ScrollView. If you want your listview have different types of items and scroll those with "normal" items you do in fact need custom adapter. You can base it on BaseAdapter if you like Adapter has to support your item types, and inflate appropriate layouts,

Alex Volovoy