您的位置:首页 > 编程语言

使用代码创建布局的小示例, 相当有用

2011-05-25 23:53 253 查看
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

TextView tv1 = new TextView(this);

tv1.setText("Hi, there!");

TextView tv2 = new TextView(this);

tv2.setText("I'm second. I need to wrap. ");

tv2.setTextSize((float) 60);



LinearLayout ll = new LinearLayout(this);

ll.setOrientation(LinearLayout.VERTICAL);

ll.addView(tv1);

ll.addView(tv2);

setContentView(ll);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: