tags:

views:

40

answers:

2

Hello all,

I am working on application wherein I need to create a List of lists. For example

EmployeeGroup1 GroupName, GroupId, JobType Empployee1 Name, Designation Empployee2 Name, Designation Empployee3 Name, Designation Empployee4 Name, Designation EmployeeGroup2 GroupName, GroupId, JobType Empployee5 Name, Designation Empployee6 Name, Designation Empployee7 Name, Designation Empployee8 Name, Designation ... And so on

The employee details in this case are retrieved from SQLite database. The employee group are fixed(5). Hence I created 5 Relative layout Groups and put a list view in each as done delow

        <RelativeLayout
        android:id="@+id/ltGroup1"          
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">   
           <TextView android:text="GroupName:" 
            android:id="@+id/lblGroupName_1" 
            android:layout_width="80dip" 
            android:layout_height="25dip"
            android:layout_alignParentLeft="true"
            android:textColor="@color/BLACK"
            android:textSize="14dip"      
            android:textStyle="bold"  
            android:paddingLeft="5dip"
            android:gravity="center" />  
            <TextView android:text="0 cal" 
            android:id="@+id/txtGroupName_1"
            android:layout_width="75dip" 
            android:layout_height="25dip"
            android:layout_toRightOf="@+id/lblGroupName_1"
            android:textColor="@color/TITLEBAR_TABS"
            android:textSize="13dip"    
            android:textStyle="bold"
            android:paddingRight="5dip"          
            android:gravity="right|center_vertical" />             
            <ListView android:id="@+id/lstEmployeeGroup_1"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:fadingEdge="none"               
             android:background="#ffffff"     
             android:scrollbars="none"
             android:divider="#ffcccccc"
             android:dividerHeight="1dip"
             android:layout_below="@+id/lblGroupName_1"/>                
        </RelativeLayout>  

If I put all the Relative layout groups in a LineraLayout and then in a Scroll View the employee list shows just one item and to see others I need to scroll through individiual list. When the screen is full the scrollview start scrolling and then I cannot scroll through individual lists also, making it worse. Is there a way wherein the employee list will always show all the records instead of showing only one?

A: 

Listview can't display all records even if it is set as height as fill_parent. It auto scroll when items are more than its display You can fix height of each list to a specific dp so that it can display a particular amount of records.

Maneesh
This works but it shows fixed number of rows. Also if the number of rows exceeds the set height then you can neither see the remaining rows nor you can scroll through list, because the scroll view moves instead of the list. Anything can be done at code level?
Tushar Vengurlekar
A: 

This is solved now. Maneesh's clue help me in getting it right. The height of the ListView needs to be set at runtim using LayoutParams property. What I have done is fixed the height of individual listitems and based on number of items I am calculating the total height of all the items at runtime and setting that value as height of listview.This did the trick for me. now the list adjusts it height based on number of the items.

Tushar Vengurlekar