【发布时间】:2014-01-20 19:30:23
【问题描述】:
我有一个名为“Editt.xml”的 xml 文件,每次单击 activty_main 中名为“@+id/Button01”的按钮时,我想将 @+id/myEditText 膨胀到 MainActivity 中
“Editt.xml”是这样的:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/myEditText"
android:layout_weight="1" /> </LinearLayout>
和“activity_main”
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:text="Button01"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
<ScrollView
android:layout_below="@id/Button01"
android:id="@+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/tableRow">
<LinearLayout
android:id="@+id/gamehistory"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</LinearLayout>
</ScrollView>
【问题讨论】:
-
使用layout inflater调用edit.xml然后使用addview方法在你的线性布局中添加视图