android.widget.TableLayout类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(12.9k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中android.widget.TableLayout类的一些代码示例,展示了TableLayout类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableLayout类的具体详情如下:
包路径:android.widget.TableLayout
类名称:TableLayout

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: firebase/firebase-jobdispatcher-android

private View createViewForJob(JobParameters job) {
 TableLayout tableLayout = new TableLayout(this);
 addRow(tableLayout, "TAG = " + job.getTag());
 addRow(tableLayout, "SERVICE = " + job.getService());
 if (job.getTriggerReason() != null
   && job.getTrigger() instanceof JobTrigger.ContentUriTrigger) {
  ContentUriTrigger trigger = (ContentUriTrigger) job.getTrigger();
  addRow(tableLayout, "OBSERVED URIs = ");
  for (ObservedUri uri : trigger.getUris()) {
   addRow(
     tableLayout,
     "URI = " + uri.getUri() + ", flags = " + Integer.toBinaryString(uri.getFlags()));
  }
  addRow(tableLayout, "TRIGGERED URIs = ");
  for (Uri uri : job.getTriggerReason().getTriggeredContentUris()) {
   addRow(tableLayout, uri.toString());
  }
 }
 ScrollView scrollView = new ScrollView(this);
 scrollView.addView(tableLayout);
 return scrollView;
}

代码示例来源:origin: stackoverflow.com

TableLayout table = (TableLayout)CheckBalanceActivity.this.findViewById(R.id.attrib_table);
for(ResourceBalance b : xmlDoc.balance_info)
{
  // Inflate your row "template" and fill out the fields.
  TableRow row = (TableRow)LayoutInflater.from(CheckBalanceActivity.this).inflate(R.layout.attrib_row, null);
  ((TextView)row.findViewById(R.id.attrib_name)).setText(b.NAME);
  ((TextView)row.findViewById(R.id.attrib_value)).setText(b.VALUE);
  table.addView(row);
}
table.requestLayout();     // Not sure if this is needed.

代码示例来源: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: realtime-framework/MessagingAndroidChat

private void setFromOtherCell() {
  LayoutInflater inflater = (LayoutInflater) context
      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View tr = inflater.inflate(R.layout.cellreceive, null, false);
  TextView user = (TextView)tr.findViewById(R.id.user);
  user.setText(msg.user +": "+ msg.date);
  TextView text = (TextView)tr.findViewById(R.id.text);
  text.setText(msg.content);
  tableMessages.addView(tr);
}

代码示例来源: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: w1123440793/VideoListDemo

public View appendRow(int layoutId, String name, String value) {
  ViewGroup rowView = (ViewGroup) LayoutInflater.from(mContext).inflate(layoutId, mTableLayout, false);
  setNameValueText(rowView, name, value);
  mTableLayout.addView(rowView);
  return rowView;
}

代码示例来源:origin: stackoverflow.com

@Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
       ProgressDialog dialog = new ProgressDialog(getActivity());
       dialog.setMessage("Loading");
       dialog.show();
       int intPos = getArguments().getInt(ARG_SECTION_NUMBER);
       View rootView;
       rootView = inflater.inflate(R.layout.fragment_main, container,false);
       TableLayout ll = (TableLayout) rootView.findViewById(R.id.tableLayoutList);
       View mTableRow = null;
       Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Far_DastNevis.otf");
       for (int i =1; i <= 2000; ++i)
       {
         mTableRow = (TableRow) View.inflate(getActivity(), R.layout.mrowrayout, null);
         final TextView txtBody = (TextView)mTableRow.findViewById(R.id.txtItem);
         txtBody.setText("Some Text" + i);
         txtBody.setId(i);
         txtBody.setTypeface(tf);
         mTableRow.setTag(i);
         ll.addView(mTableRow);
       }
       return rootView;
     }

代码示例来源:origin: stackoverflow.com

public class SeleccionarJugador extends Activity {

private TableLayout mTablaJugadores;

@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);

  // Se establece el layout
  setContentView(R.layout.jugadores);

  // Se recupera la tabla donde se insertán los jugadores de ambos equipos
  mTablaJugadores = (TableLayout) findViewById(R.id.tabla_jugadores);
  LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

  TableRow fila = new TableRow(this);
  View v = inflater.inflate(R.layout.fila_seleccionar_jugadores,null);
  TextView dorsal = (TextView) v.findViewById(R.id.dorsal);
  dorsal.setText(String.valueOf(11));
  TextView nombre = (TextView) v.findViewById(R.id.nombre);
  nombre.setText("Pepe");
  TextView posicion = (TextView) v.findViewById(R.id.posicion);
  posicion.setText("Lateral");
  fila.addView(v);
  mTablaJugadores.addView(fila);

}

代码示例来源:origin: stackoverflow.com

public class MyActivity extends Activity {

  private TableLayout tableLayout;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.table);
    tableLayout=(TableLayout)findViewById(R.id.tableLayout);

    for (int i=0;i<5;i++){
      View tableRow = LayoutInflater.from(this).inflate(R.layout.table_item,null,false);
      TextView history_display_no  = (TextView) tableRow.findViewById(R.id.history_display_no);
      TextView history_display_date  = (TextView) tableRow.findViewById(R.id.history_display_date);
      TextView history_display_orderid  = (TextView) tableRow.findViewById(R.id.history_display_orderid);
      TextView history_display_quantity  = (TextView) tableRow.findViewById(R.id.history_display_quantity);

      history_display_no.setText(""+(i+1));
      history_display_date.setText("2014-02-05");
      history_display_orderid.setText("S0"+(i+1));
      history_display_quantity.setText(""+(20+(i+1)));
      tableLayout.addView(tableRow);
    }
  }
}

代码示例来源: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 ");
tv3.setTextColor(Color.WHITE);
tbrow0.addView(tv3);
stk.addView(tbrow0);
for (int i = 0; i < 25; i++) {
  TableRow tbrow = new TableRow(this);
  t4v.setGravity(Gravity.CENTER);
  tbrow.addView(t4v);
  stk.addView(tbrow);

代码示例来源:origin: stackoverflow.com

TableLayout tableLayout = (TableLayout) findViewById(R.id.tablelayout);
for (int j = 0; j < 50; j++) {
TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
for (int i = 0; i < 10; i++) {
TextView t = new TextView(this);
t.setText("Dynamic TV");
t.setPadding(10, 10, 10, 10);
t.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
tableRow.addView(t);

// Add vertical separator
        View v = new View(this);
        v.setLayoutParams(new TableRow.LayoutParams(1, TableRow.LayoutParams.MATCH_PARENT));
        v.setBackgroundColor(Color.rgb(50, 50, 50));
        tableRow.addView(v);
      }
      // Added Horizontal line as
      View view = new View(this);
      view.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, 1));
      view.setBackgroundColor(Color.rgb(50, 50, 50));
      tableLayout.addView(view);

tableLayout.addView(tableRow, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT, 0.1f));

代码示例来源:origin: stackoverflow.com

// try this
TableLayout tableLayout = (TableLayout)findViewById(R.id.tabContentLayout);
   tableLayout.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,TableLayout.LayoutParams.WRAP_CONTENT));
   tableLayout.removeAllViews();
   for(int i=0;i<rows.length;i++){
     Log.d("Rows",rows[i]);
     String row  = rows[i];
     TableRow tableRow = new TableRow(this);
     tableRow.setBackgroundResource(R.drawable.cell_shape);
     tableRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
     final String[] cols = row.split(";");
     Log.i(LOG_CLASS, "<<---- Columns count : " + cols.length + " ---->>");
     for (int j = 0; j < cols.length; j++) {
       final String col = cols[j];
       TextView columsView = new TextView(getApplicationContext());
       columsView.setBackgroundResource(R.drawable.cell_header);
       columsView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
       columsView.setTextColor(color.white);
       columsView.setTextSize(TypedValue.COMPLEX_UNIT_SP,15);
       columsView.setGravity(Gravity.CENTER);
       columsView.setText(String.format("%7s", col));
       Log.d("Cols", String.format("%7s", col));
       tableRow.addView(columsView);
     }
     tableLayout.addView(tableRow);
   }
   tableLayout.requestLayout();

代码示例来源: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: firelotus/Meteorite

firstrowlp.weight = 1;
TextView maintext = new TextView(DBFlowManagerActivity.this);
maintext.setText("Select Table");
maintext.setTextSize(22);
maintext.setLayoutParams(firstrowlp);
select_table=new Spinner(DBFlowManagerActivity.this);
tableLayout = new TableLayout(DBFlowManagerActivity.this);
tableLayout.setHorizontalScrollBarEnabled(true);
hsv.addView(tableLayout);

代码示例来源: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: infinum/android_dbinspector

private void showContent() {
  showingContent = true;
  tableLayout.removeAllViews();
  List<TableRow> rows = adapter.getContentPage();
  for (TableRow row : rows) {
    tableLayout.addView(row);
  }
  currentPageText.setText(adapter.getCurrentPage() + "/" + adapter.getPageCount());
  contentHeader.setVisibility(View.VISIBLE);
  nextButton.setEnabled(adapter.hasNext());
  previousButton.setEnabled(adapter.hasPrevious());
}

代码示例来源: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

public void createTableRow(String textBoxContent,Integer catId) {
  TableLayout tl = (TableLayout) findViewById(R.id.SelectCat);
  TableRow tr = new TableRow(this);
  LayoutParams lp = new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
  tr.setLayoutParams(lp);
  tr.setGravity(Gravity.RIGHT);
  Button btnLeft = new Button(this);
  btnLeft.setLayoutParams(new LayoutParams(0,android.view.ViewGroup.LayoutParams.WRAP_CONTENT,(float) 0.5));
  btnLeft.setText(R.string.Show);
  btnLeft.setTag(catId);
  TextView tvCenter = new TextView(this);
  tvCenter.setLayoutParams(new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
  tvCenter.setBackgroundColor(Color.WHITE);
  tvCenter.setText(textBoxContent);
  tr.addView(btnLeft);
  tr.addView(tvCenter);
  tl.addView(tr, new TableLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
 }

代码示例来源: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);
    View cell = layoutInflater.inflate(R.layout.table_cell, null, false);
    if (cellHeight == 0 ) {
      cell.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
      cellWidth = cell.getMeasuredWidth();
      cellHeight = cell.getMeasuredHeight();
    tableRow.addView(cell);
  tableLayout.addView(tableRow);

相关文章