本文整理了Java中android.widget.TableLayout.addView()
方法的一些代码示例,展示了TableLayout.addView()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableLayout.addView()
方法的具体详情如下:
包路径:android.widget.TableLayout
类名称:TableLayout
方法名:addView
暂无
代码示例来源:origin: stackoverflow.com
// reference the table layout
TableLayout tbl = (TableLayout)findViewById(R.id.RHE);
// delcare a new row
TableRow newRow = new TableRow(this);
// add views to the row
newRow.addView(new TextView(this)); // you would actually want to set properties on this before adding it
// add the row to the table layout
tbl.addView(newRow);
代码示例来源:origin: stackoverflow.com
private void addTableRow() {
final TableLayout table = (TableLayout) findViewById(R.id.my_table);
final TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.table_row_item, null);
TextView tv;
// Fill out our cells
tv = (TextView) tr.findViewById(R.id.cell_1);
tv.setText(...);
...
tv = (TextView) tr.findViewById(R.id.cell_N);
tv.setText(...);
table.addView(tr);
// Draw separator
tv = new TextView(this);
tv.setBackgroundColor(Color.parseColor("#80808080"));
tv.setHeight(/*height of separaor line. 2dip will be enough*/);
table.addView(tv);
// If you use context menu it should be registered for each table row
registerForContextMenu(tr);
}
代码示例来源:origin: stackoverflow.com
/* Find Tablelayout defined in main.xml */
TableLayout tl = (TableLayout) findViewById(R.id.SaleOrderLines);
/* Create a new row to be added. */
TableRow tr = new TableRow(this);
tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
/* Create a Button to be the row-content. */
Button b = new Button(this);
b.setText("Dynamic Button");
b.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
/* Add Button to row. */
tr.addView(b);
/* Add row to TableLayout. */
//tr.setBackgroundResource(R.drawable.sf_gradient_03);
tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT));
代码示例来源:origin: stackoverflow.com
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
TableLayout tableLayout = new TableLayout(getApplicationContext());
TableRow tableRow;
TextView textView;
for (int i = 0; i < 4; i++) {
tableRow = new TableRow(getApplicationContext());
for (int j = 0; j < 3; j++) {
textView = new TextView(getApplicationContext());
textView.setText("test");
textView.setPadding(20, 20, 20, 20);
tableRow.addView(textView);
}
tableLayout.addView(tableRow);
}
setContentView(tableLayout);
}
代码示例来源:origin: stackoverflow.com
TableLayout layout = (TableLayout)mainLayout.findViewById(R.id.my_table_layout_id);
for(int i = 0; i < 10; i++) {
row = new TableRow(this);
View layout_number = inflater.inflate(R.layout.inflate_number, layout, false);
TextView number = (TextView) layout_number.findViewById(R.id.Number);
number.setTag(i);
number.setText(Integer.toString(i));
row.addView(number);
layout.addView(row);
}
代码示例来源:origin: stackoverflow.com
TableLayout tblServices = (TableLayout) findViewById(R.id.tblServices);
TableRow row = new TableRow(this);
row.setLayoutParams(new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
TextView tvName = new TextView(this);
tvName.setLayoutParams(new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
tblServices.addView(row, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
代码示例来源:origin: stackoverflow.com
TableLayout tl=(TableLayout)findViewById(R.id.tLayout);
TableRow tr1 = new TableRow(this);
//to add row on table ,you can use loops to add multiple rows on table
tl.addView(tr1);
代码示例来源:origin: stackoverflow.com
TableLayout prices = (TableLayout)findViewById(R.id.prices);
prices.setStretchAllColumns(true);
prices.bringToFront();
for(int i = 0; i < drug.length; i++){
TableRow tr = new TableRow(this);
TextView c1 = new TextView(this);
c1.setText(drug[i].getName());
TextView c2 = new TextView(this);
c2.setText(String.valueOf(drug[i].getPrice()));
TextView c3 = new TextView(this);
c3.setText(String.valueOf(drug[i].getAmount()));
tr.addView(c1);
tr.addView(c2);
tr.addView(c3);
prices.addView(tr);
}
代码示例来源:origin: stackoverflow.com
private void AddRow(String rowNo)
{
final TableLayout table = (TableLayout) findViewById(R.id.my_table);
final TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.table_row_item, null);
tr.setTag(rowNo);
TextView tv;
tv = (TextView) tr.findViewById(R.id.rowNo);
tv.setText(rowNo);
table.addView(tr);
tr.setOnClickListener(mClickListener);
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
private void addRow(TableLayout tableLayout, String text) {
TableRow tableRow = new TableRow(this);
TextView textView = new TextView(this);
textView.setText(text);
tableRow.addView(textView);
tableLayout.addView(tableRow);
}
}
代码示例来源:origin: stackoverflow.com
// Retrieve some elements from the layout
TableLayout table = (TableLayout)findViewById(R.id.button_table);
TableRow row = (TableRow)findViewById(R.id.button_row_0);
NiceButton origButton = (NiceButton)findViewById(R.id.button_0);
// Prepare button 0
origButton.setId(0);
origButton.setText("Button 0");
origButton.setOnClickListener(mNiceButtonClickListener);
mButtonViews[0] = origButton;
// Create buttons 1 to 10
for (int i = 1; i < 10; i++) {
if (i % 2 == 0) {
row = new TableRow(this);
table.addView(row);
}
NiceButton button = new NiceButton(i, origButton);
button.setText("Button " + i);
button.setOnClickListener(mNiceButtonClickListener);
mButtonViews[i] = button;
row.addView(button);
}
代码示例来源:origin: stackoverflow.com
TableLayout ll = (TableLayout) findViewById(R.id.tableLayout);
for (int i = 0; i < 4; i++) {
TableRow row= new TableRow(this);
TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT);
row.setLayoutParams(lp);
//add your buttons and stuff
ll.addView(row,i);
}
}
代码示例来源:origin: stackoverflow.com
TableRow tbrow0 = new TableRow(this);
TextView tv0 = new TextView(this);
tv0.setText(" Sl.No ");
tv0.setTextColor(Color.WHITE);
tbrow0.addView(tv0);
TextView tv1 = new TextView(this);
tv1.setText(" Product ");
tv1.setTextColor(Color.WHITE);
tbrow0.addView(tv1);
TextView tv2 = new TextView(this);
tv2.setText(" Unit Price ");
tv2.setTextColor(Color.WHITE);
tbrow0.addView(tv2);
TextView tv3 = new TextView(this);
tv3.setText(" Stock Remaining ");
tv3.setTextColor(Color.WHITE);
tbrow0.addView(tv3);
stk.addView(tbrow0);
for (int i = 0; i < 25; i++) {
TableRow tbrow = new TableRow(this);
TextView t1v = new TextView(this);
t1v.setText("" + i);
t4v.setGravity(Gravity.CENTER);
tbrow.addView(t4v);
stk.addView(tbrow);
代码示例来源:origin: stackoverflow.com
TableLayout table = (TableLayout)findViewById(R.id.table);
LayoutInflater inflater = getLayoutInflater();
for(int i = 0; i < 10; i++) {
TableRow row = (TableRow)inflater.inflate(R.id.table_row,
table, false);
TextView text = (TextView)row.findViewById(R.id.text);
text.setText("row: " + i);
// other customizations to the row
table.addView(row);
}
代码示例来源:origin: THEONE10211024/ApiDemos
private void appendRow(TableLayout table) {
TableRow row = new TableRow(this);
TextView label = new TextView(this);
label.setText(R.string.table_layout_8_quit);
label.setPadding(3, 3, 3, 3);
TextView shortcut = new TextView(this);
shortcut.setText(R.string.table_layout_8_ctrlq);
shortcut.setPadding(3, 3, 3, 3);
shortcut.setGravity(Gravity.RIGHT | Gravity.TOP);
row.addView(label, new TableRow.LayoutParams(1));
row.addView(shortcut, new TableRow.LayoutParams());
table.addView(row, new TableLayout.LayoutParams());
}
}
代码示例来源:origin: stackoverflow.com
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Setup this activity's view.
setContentView(R.layout.game_board);
TableLayout table = (TableLayout) findViewById(R.id.table);
int gridSize = 5;
// Create the table elements and add to the table.
int uniqueId = 1;
for (int i = 0; i < gridSize; i++) {
// Create table rows.
TableRow row = new TableRow(this);
row.setId(uniqueId++);
for (int j = 0; j < gridSize; j++) {
// Create buttons.
Button button = new Button(this);
button.setId(uniqueId++);
row.addView(button);
}
// Add row to the table.
table.addView(row);
}
}
代码示例来源:origin: stackoverflow.com
HSV.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
TableRow tblRow = new TableRow(this);
tblRow.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
tblRow.setBackgroundResource(R.drawable.bookshelf);
imageView.setImageResource(R.drawable.book1);
TextView textView = new TextView(this);
textView.setText("Java Tester");
textView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
tblRow.addView(imageView,j);
tblLayout.addView(HSV, i);
代码示例来源:origin: stackoverflow.com
public class TestActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LayoutInflater inflater = getLayoutInflater();
TableRow row = (TableRow) inflater.inflate(R.layout.myrow, null);
TextView text = (TextView) row.findViewById(R.id.text);
text.setText("I did all your work... smart even");
TableLayout table = (TableLayout) findViewById(R.id.schedule_table_entry);
table.addView(row);
}
代码示例来源:origin: qiubiteme/android_api_demos
private void appendRow(TableLayout table) {
TableRow row = new TableRow(this);
TextView label = new TextView(this);
label.setText(R.string.table_layout_8_quit);
label.setPadding(3, 3, 3, 3);
TextView shortcut = new TextView(this);
shortcut.setText(R.string.table_layout_8_ctrlq);
shortcut.setPadding(3, 3, 3, 3);
shortcut.setGravity(Gravity.RIGHT | Gravity.TOP);
row.addView(label, new TableRow.LayoutParams(1));
row.addView(shortcut, new TableRow.LayoutParams());
table.addView(row, new TableLayout.LayoutParams());
}
}
代码示例来源:origin: stackoverflow.com
tableLayout.setStretchAllColumns(true);
for (int i = 0; i < 4; i++) {
TableRow tableRow = new TableRow(this);
for (int j = 0; j < 10; j++) {
LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
tableRow.addView(cell);
tableLayout.addView(tableRow);
内容来源于网络,如有侵权,请联系作者删除!