Pan*_*mar 2 java android tablelayout android-layout
我想在表格布局中显示数据.数据的数量是动态的,因此我需要在表中实现动态行.为此,我想在一行中显示4个TextView.
问题
目前,我能够在表格和四个TextView中显示数据,但我想在所有四个EditText之间有一些空格,但无法做到.
这是我的代码
for(ItemRow row : this.getRows()) {
if(row != null) {
// delcare a new row
newRow = new TableRow(this);
newRow.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
newRow.setPadding(0, 2, 0, 2);
column1 = new TextView(this);
column2 = new TextView(this);
column3 = new TextView(this);
column4 = new TextView(this);
column1.setTextColor(Color.BLACK);
column2.setTextColor(Color.BLACK);
column3.setTextColor(Color.BLACK);
column4.setTextColor(Color.BLACK);
column1.setSingleLine(false);
column2.setSingleLine(false);
column3.setSingleLine(false);
column4.setSingleLine(false);
if(row.getColumnOne() != null){
column1.setText(row.getColumnOne());
}
if(row.getColumnTwo() != null) {
column2.setText(row.getColumnTwo());
}
if(row.getColumnThree() != null) {
column3.setText(row.getColumnThree());
}
if(row.getColumnFour() != null) {
column4.setText(row.getColumnFour());
}
//Now add a row
newRow.addView(column1);
newRow.addView(column2);
newRow.addView(column3);
newRow.addView(column4);
//Add row to table
table.addView(newRow, new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的输出:

需要
我需要列之间的空格.我该怎么做?
| 归档时间: |
|
| 查看次数: |
1958 次 |
| 最近记录: |