像這個?:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Buddy Name"
android:inputType="textPersonName" >
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Email Address"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Information" />
</LinearLayout>
編輯:
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.editTextGroupLayout);
linearLayout.setOrientation(LinearLayout.VERTICAL);
EditText editTextView = new EditText(this);
editTextView.setGravity(Gravity.CENTER);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT, 1);
editTextView.setLayoutParams(params);
linearLayout.addView(editTextView);
Source
是的,但我想以編程方式添加它們... – Mageek
@Mageek:檢查我的編輯。 – fida1989
@Mageek看到fida粘貼你需要的代碼 – Trikaldarshi