how to add edittext to a linearlayout dynamically at desired positions to the linearlayout in android
I am new to android ,Actually i want to add edittexts to a relativelayout or linearlayout at desired po开发者_如何学Pythonsitions on the layout .plz suggest me. thanks in advance..
Do you really need add an EditText programmatically?
Usually it is enough to hide certain Views and change the visibility programmatically.
<EditText android:id="@+id/view_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
/>
The three values for visibility are "visible", "invisible" and "gone". "gone" means the EditText is taking no space. "invisible" means that the space it would take is empty.
You can change the visibility the following way:
EditText editText = (EditText) findViewById(R.id.view_name);
editText.setVisibility(View.VISIBLE);
精彩评论