Cómo configurar layout_span a través del código

Does anyone know how to set/change the android:layout_span="" of an EditText in Android at runtime. I already have the EditText defined in my XML file.

<TableRow android:paddingTop="20dip" android:gravity="center_horizontal">  

    <EditText android:layout_width="150dip" 


preguntado el 09 de enero de 11 a las 01:01

1 Respuestas

Puedes usar:

TableRow.LayoutParams params = (TableRow.LayoutParams)editText.getLayoutParams();
params.span = toSpan;
editText.setLayoutParams(params); // causes layout update

Respondido el 09 de enero de 11 a las 04:01

but where it is stating that the layout_span = 2?? if I want to make layout_span=3 or layout_span=4?? then? - Sharda Singh

params.span = toSpan; You can assign your span value either 2 or 3 or 4 to toSpan variable TextView txtView; params.span = 4; txtView.setLayoutParams(params); - Sankar R.K

Nice, and there I was looking all over for a function that would return the span. Hidden in plain sight! - RTF

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.