Hi, I need to add some parts of my UI programmatically. I'm doing this because I need to set the ids of some elements up in such a way that they can be easily access in a for loop. So far I have this xml:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/attr_row" android:layout_width="fill_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/attr_name" android:hint="Attribute" android:layout_width="0dip" android:layout_weight="2" android:layout_height="wrap_content" android:inputType="textPersonName" /> <EditText android:id="@+id/attr_val" android:hint="Value" android:layout_width="0dip" android:layout_weight="3" android:layout_height="wrap_content" android:inputType="textPersonName" /> <ImageButton android:id="@+id/drop_attr" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/btn_delete_states" android:layout_gravity="center_vertical" /> </LinearLayout> At the moment, I inflate this xml five times like so: for (int i = 0; i<5; i++) { LinearLayout attrList = (LinearLayout) findViewById (R.id.attr_list); LayoutInflater inflater = getLayoutInflater(); View row = inflater.inflate(R.layout.attr_row, null); LinearLayout extraAttr = (LinearLayout) row.findViewById (R.id.attr_row); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); attrList.addView(extraAttr, i, params); } The link below shows two pictures - the layout hierarchy and the result in the emulator. http://picasaweb.google.com/bengoldcross/Android?authkey=Gv1sRgCJ785IS-2M_tmgE&feat=directlink As can be seen, the xml is inflated five times successfully but only one is actually displayed. Inspecting the hierarchy viewer a bit more explains why. The layout being displayed is at location x=0 y=111 all the others are being rendered at x=320 y=111. It would appear they are being displayed a) off screen and b) on top of each other. So.. why are they and how do I stop it from happening? -- 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

