您的位置:首页 > 移动开发 > Android开发

Android开发之TableLayout文本组件…

2013-12-30 20:37 344 查看




该种方法,操作复杂,不推荐使用。

直接在我们的src下边的程序当中

public class MainActivity
extends Activity {

private String
titleData[][]=new String[][]{
{"ID","姓名","EMAIL","地址"},
{"1","包汉青","bao@yeah.net","山东临沂"},
{"2","张三","zhangsan.126.com","中国北京"}
};

protected void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
TableLayout layout=new
TableLayout(this);
TableLayout.LayoutParams
layoutParam=new TableLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT);
//设置背景
layout.setBackgroundColor(R.drawable.ic_launcher);
for(int
i=0;i<this.titleData.length;i++){
 
  TableRow row=new
TableRow(this);
 
  for(int
j=0;j<this.titleData.length;j++){
TextView tx=new
TextView(this);
tx.setText(titleData[i][j]);
row.addView(tx,j);
 
  }
  layout.addView(row);
}
super.setContentView(layout,layoutParam);
 
 }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: