-2
У меня есть файл XML с именем «Editt.xml
», я хочу, чтобы раздуть @+id/myEditText
в MainActivity каждый раз, когда я нажимаю кнопку с activty_main
названием «@+id/Button01
»Я хочу, чтобы раздуть файл XML в 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>
Используйте макет надувных для вызова edit.xml, затем используйте метод addview, чтобы добавить представление в линейную компоновку –