문제

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" 
         android:text=""
         android:layout_height="40dip" 
         android:id="@+id/p"
         android:layout_span="2">
    </EditText>

</TableRow>
도움이 되었습니까?

해결책

You can use:

TableRow.LayoutParams params = (TableRow.LayoutParams)editText.getLayoutParams();
params.span = toSpan;
editText.setLayoutParams(params); // causes layout update
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top