2014-01-20 2 views
-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> 

+0

Используйте макет надувных для вызова edit.xml, затем используйте метод addview, чтобы добавить представление в линейную компоновку –

ответ

0
View v = getInflater().inflate(Editt.xml,null); 

LinearLayout linearLayout = (LinearLayout) findViewById(R.layout.game_layout); 
linearLayout.addView(v); 
Смежные вопросы