2012年4月1日 星期日

【Android】add a layout file into current activity

If layout flie(e.g. layout.xml) need to add to acticity using hardcard,below code is ths example

  1: controlInflater = LayoutInflater.from(getBaseContext());
  2:         View viewControl = controlInflater.inflate(R.layout.control, null);
  3:         LayoutParams layoutParamsControl 
  4:             = new LayoutParams(LayoutParams.FILL_PARENT, 
  5:             LayoutParams.FILL_PARENT);
  6:         this.addContentView(viewControl, layoutParamsControl);

沒有留言:

張貼留言