Hi there, I am working on a little Activity with a ListView. This ListView should contain rows, that are LinearLayouts with vertical orientation created by a custom Adapter based on the BaseAdapter. The Adapter also creates a couple of RelativeLayouts (with three TextViews) that should be childs of a single row-linear-layout. The number of the RelativeLayouts depends on the dataset at that specific position.
Well, the ListView and Adapter seem to work, but the whole layout of a single row is not as intended. A single row (with the vertical LinearLayout) eats up nearly the whole space of the ListView and only the content of the first subrow is shown, leaving the rest of space empty. As first I thought, that there is somewhere placed a layout_height="fill_parent" at the wrong place, but there isn't. I looked here in the archives, but couldn't find anything appropriate to that problem. Do I need an ExpandableListView (but without the dynamic expansion, only with dynamic creation)? Can someone point me to the right direction? Cheers, Rutton. The ListView Layout looks like that: <ListView> <LinearLayout> --- beginning of a row <RelativeLayout> -- subrow no. 1 (dynamically generated) <TextView/> <TextView/> <TextView/> </RelativeLayout> .... <RelativeLayout> -- subrow no. n (dynamically generated) ... </RelativeLayout> </LinearLayout> -- end of a row .... --- next row </ListView> For this, I have written a simple ListActivity (to simplify for now) that contains two layout files. This is for a single row in the ListView, it's more or less a place marker. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:id="@+id/searchitem" android:layout_width="fill_parent" android:layout_height="wrap_content" orientation="vertical"> </LinearLayout> And the following (there can be more than one of them) should be contained in each row (see the LinearLayout above). <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:id="@+id/searchrow" android:layout_width="fill_parent" android:layout_height="wrap_content" orientation="horizontal"> <TextView android:id="@+id/searchitemleft" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_toLeftOf="@+id/ centermargin" android:gravity="left"> </TextView> <TextView android:id="@+id/centermargin" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true"> </TextView> <TextView android:id="@+id/searchitemright" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_toRightOf="@ +id/centermargin" android:gravity="right" android:paddingRight="12dp"> </TextView> </RelativeLayout> The related code (an example version) in the Adapter to create this constellation is the following: @Override public View getView(int position, View convertView, ViewGroup parent) { LinearLayout ll; Log.d( TAG, "MyAdapter: -- starting -- "); if( convertView == null ) { ll = (LinearLayout) LayoutInflater.from(ctx).inflate( R.layout.item, parent, false ); Log.d( TAG, "MyAdapter: generating new ll." ); } else { ll = (LinearLayout) convertView; Log.d( TAG, "MyAdapter: LL childcount is " + ll.getChildCount() + "."); } int maxSize = 3; // the subrow size is fixed in this example Log.d( TAG, "MyAdapter: maxSize=" + maxSize + "."); int i = 0; // maxSize = 1; while ( i < maxSize ) { RelativeLayout crrLayout; if ( i < ll.getChildCount()) crrLayout = (RelativeLayout)ll.getChildAt( i ); else { Log.d(TAG, "MyAdapter: creating new child at position " + i + "."); crrLayout = (RelativeLayout) LayoutInflater.from(ctx).inflate( R.layout.itemrow, ll, false ); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT ); ll.addView(crrLayout, i, lp); // ll.addView( crrLayout ); } TextView searchItemLeft = (TextView) crrLayout.findViewById( R.id.searchitemleft); searchItemLeft.setText( st.getLeftString() + " " + i ); TextView searchItemRight = (TextView) crrLayout.findViewById( R.id.searchitemright); searchItemRight.setText( st.getRightString() + " " + i ); i++; } while( i < ll.getChildCount()) { ll.removeViewAt( i ); i++; } Log.d( TAG, "MyAdapter: number of rows is " + i + "." ); Log.d( TAG, "MyAdapter: -- ending -- "); return ll; } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en