package com.feidaochuanqing.uibycode;
import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout layout = new LinearLayout(this);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
TextView textView = new TextView(this);
textView.setWidth(ViewGroup.LayoutParams.FILL_PARENT);
textView.setHeight(ViewGroup.LayoutParams.FILL_PARENT);
textView.setText("文本文件");
textView.setId(22);
//添加的时候注意协商布局参数
layout.addView(textView,layoutParams);
//这里原来指向的是资源id,现在改为自定义的控件
setContentView(layout,layoutParams);
}
}