Found the problem: Change TableLayout.LayoutParams to TableRow.LayoutParams
On Mon, Nov 1, 2010 at 11:32 PM, EvgenyV <evgen...@gmail.com> wrote: > Hi all, > > I'm trying to create table row and place 3 elements: EditText - > EditText - ImageButton as following: > > TableLayout tableUnits = > (TableLayout)findViewById(R.id.tableUnits); > > TableRow tr = new > TableRow(ViewNewElementBase.this); > > EditText txtMesureName = new > EditText(ViewNewElementBase.this); > txtMesureName.setLayoutParams(new > TableLayout.LayoutParams( > 0, > TableLayout.LayoutParams.FILL_PARENT, 1f)); > > txtMesureName.setImeOptions(EditorInfo.IME_ACTION_NEXT); > > txtMesureName.setFocusableInTouchMode(true); > txtMesureName.setFocusable(true); > txtMesureName.setLines(1); > txtMesureName.setId(1000); > tr.addView(txtMesureName); > > EditText txtRatio = new > EditText(ViewNewElementBase.this); > txtRatio.setLayoutParams(new > TableLayout.LayoutParams( > 0, > TableLayout.LayoutParams.FILL_PARENT, 1f)); > > txtRatio.setImeOptions(EditorInfo.IME_ACTION_DONE); > txtRatio.setFocusableInTouchMode(true); > txtRatio.setFocusable(true); > txtRatio.setLines(1); > > txtRatio.setInputType(InputType.TYPE_CLASS_NUMBER | > InputType.TYPE_CLASS_PHONE | InputType.TYPE_NUMBER_FLAG_SIGNED | > InputType.TYPE_NUMBER_FLAG_DECIMAL); > txtRatio.setId(1001); > tr.addView(txtRatio); > > ImageButton button = new > ImageButton(ViewNewElementBase.this); > > button.setImageResource(R.drawable.trash_32); > button.setLayoutParams(new > TableLayout.LayoutParams( > > TableLayout.LayoutParams.FILL_PARENT, > TableLayout.LayoutParams.FILL_PARENT)); > button.setId(1002); > tr.addView(button); > > tableUnits.addView(tr, new > TableLayout.LayoutParams( > > TableLayout.LayoutParams.FILL_PARENT, > > TableLayout.LayoutParams.WRAP_CONTENT)); > > Please advise what can be a reason the row is not displayed? > > I'm getting same issue described time ago > > http://www.warriorpoint.com/blog/2009/07/01/android-creating-tablerow-rows-inside-a-tablelayout-programatically/ > But in my case I have to set LayoutParams to make sure both EditText > elements are equal and both filling the whole row. > > The same row layout xml equivalent is: > > <TableRow> > <EditText > android:layout_weight="1" > android:layout_height="fill_parent" > android:layout_width="0dip" > android:imeOptions="actionNext" > android:focusableInTouchMode="true" > android:focusable="true" > android:lines="1" > > </EditText> > <EditText > android:layout_weight="1" > android:layout_height="fill_parent" > > android:layout_width="0dip" > > android:imeOptions="actionDone" > android:focusableInTouchMode="true" > android:focusable="true" > android:lines="1" > > android:inputType="number|numberSigned|numberDecimal|phone"> > </EditText> > <ImageButton > android:id="@+id/btnRemoveUnit" > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:src="@drawable/trash_32"> > </ImageButton> > </TableRow> > > <TableLayout > android:id="@+id/tableUnits" > android:layout_height="wrap_content" > android:orientation="vertical" > android:gravity="center_horizontal" > android:layout_width="fill_parent" > android:paddingTop="3dip" > android:background="@color/my_color" > /> > > Thanks in advance, > Evgeny -- 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