protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); LinearLayout LL= (LinearLayout) findViewById(R.id.ll); //View.inflate(this,R.layout.items,LL); View view=View.inflate(this,R.Layout.items,null); }
root 根 类型ViewGroup控件组 LinearLayout等布局都继承ViewGroup 如果root为空,打气筒将R.layout.items布局打成一个VIEW组件,若不为空,则将该VIEW组件直接添加到ViewGroup(一个副布局)中去,则在显示的时候会连同副布局一起显示出来