Android獲得壹個布局控件,並將其添加到另壹個布局中。
受保護的void onCreate(Bundle saved instancestate){
super . oncreate(savedInstanceState);
setContentView(r . layout . activity _ main);
linear layout relative layout =(linear layout)findViewById(r . id . layout 456);
ImageView imgApple2 =新ImageView(this);
imgapple 2 . setimageresource(r . drawable . IC _ launcher);
relative layout . add view(imgapple 2);
LayoutInflater factory ys = LayoutInflater . from(main activity . this);
最終視圖textEntryView = factory ys . inflate(r . layout . layout 1,null);
//linear layout linear layout =(linear layout)textEntryView
// .findViewById(r . id . layout 1);
//relative layout . add view(linear layout);
EditText EditText 1 =(EditText)textEntryView
。findViewById(r . id . edittext 1);
relative layout . add view(edittext 1);