Example usage for android.widget TableRow addView

List of usage examples for android.widget TableRow addView

Introduction

In this page you can find the example usage for android.widget TableRow addView.

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:com.dicent.DiceFragment.java

public void refreshDice() {
    if (diceTable == null || diceList == null)
        return;//from w  w  w .  j a  v  a2  s. c o m
    DisplayMetrics metrics = getActivity().getResources().getDisplayMetrics();
    int columns = metrics.widthPixels / (int) ((Die.scale + Die.margin) * metrics.density);
    diceTable.removeAllViews();
    TableRow tr = null;
    int addedDice = 0;
    for (int i = 0; i < diceList.size(); i++) {
        if (!diceList.get(i).isVisible())
            continue;
        if (addedDice % columns == 0) {
            tr = new TableRow(getActivity());
            diceTable.addView(tr);
        }
        Die die;
        if (diceList.get(i) instanceof FirstEdDieData)
            die = new FirstEdDie(getActivity(), (FirstEdDieData) diceList.get(i));
        else
            die = new SecondEdDie(getActivity(), (SecondEdDieData) diceList.get(i));
        die.setOnClickListener(new OnDieClickedListener(die));
        tr.addView(die);
        addedDice++;
    }
}

From source file:tinygsn.gui.android.ActivityViewData.java

private void addTableViewModeLatest() {
    table_view_mode = (TableLayout) findViewById(R.id.table_view_mode);
    // table_view_mode.setLayoutParams(new
    // TableLayout.LayoutParams(LayoutParams.FILL_PARENT,
    // LayoutParams.WRAP_CONTENT));
    table_view_mode.removeAllViews();/*ww w.j  a  v  a  2s.  c om*/

    TableRow row = new TableRow(this);

    TextView txt = new TextView(this);
    txt.setText("         View ");
    txt.setTextColor(Color.parseColor("#000000"));
    row.addView(txt);

    final EditText editText_numLatest = new EditText(this);
    editText_numLatest.setText("10");
    editText_numLatest.setInputType(InputType.TYPE_CLASS_NUMBER);
    editText_numLatest.requestFocus();
    editText_numLatest.setTextColor(Color.parseColor("#000000"));
    row.addView(editText_numLatest);

    editText_numLatest.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            try {
                numLatest = Integer.parseInt(editText_numLatest.getText().toString());
                loadLatestData();
            } catch (NumberFormatException e) {
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
                alertDialogBuilder.setTitle("Please input a number!");
            }
        }
    });

    txt = new TextView(this);
    txt.setText(" latest values");
    txt.setTextColor(Color.parseColor("#000000"));
    row.addView(txt);

    txt = new TextView(this);
    txt.setText("            ");
    row.addView(txt);
    table_view_mode.addView(row);

    row = new TableRow(this);
    Button detailBtn = new Button(this);
    // plotDataBtn.setTextSize(TEXT_SIZE);
    detailBtn.setText("Detail");
    detailBtn.setTextColor(Color.parseColor("#000000"));
    detailBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            //            Toast.makeText(context, "detailBtn is clicked",
            //                  Toast.LENGTH_SHORT).show();

            showDialogDetail();
        }
    });

    Button plotDataBtn = new Button(this);
    // plotDataBtn.setTextSize(TEXT_SIZE);
    plotDataBtn.setText("Plot data");
    plotDataBtn.setTextColor(Color.parseColor("#000000"));
    plotDataBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            viewChart();
        }
    });

    TableRow.LayoutParams params = new TableRow.LayoutParams();
    // params.addRule(TableRow.LayoutParams.FILL_PARENT);
    params.span = 2;

    row.addView(detailBtn, params);
    row.addView(plotDataBtn, params);
    row.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    table_view_mode.addView(row);
}

From source file:mx.udlap.is522.tedroid.activity.ScoresActivity.java

/** @return la fila de encabezados de la tabla. */
private TableRow createHeaderRow() {
    TableRow headerRow = new TableRow(this);
    TextView pointsHeaderText = new TextView(this);
    pointsHeaderText.setText(R.string.points_header);
    applyPrimaryStyleTo(pointsHeaderText);
    TextView levelHeaderText = new TextView(this);
    levelHeaderText.setText(R.string.level_header);
    applyPrimaryStyleTo(levelHeaderText);
    TextView linesHeaderText = new TextView(this);
    linesHeaderText.setText(R.string.lines_header);
    applyPrimaryStyleTo(linesHeaderText);
    TextView dateHeaderText = new TextView(this);
    dateHeaderText.setText(R.string.date_header);
    applyPrimaryStyleTo(dateHeaderText);
    headerRow.addView(pointsHeaderText);
    headerRow.addView(levelHeaderText);//from ww w  .j  a va 2  s  .  co  m
    headerRow.addView(linesHeaderText);
    headerRow.addView(dateHeaderText);
    return headerRow;
}

From source file:tinygsn.gui.android.ActivityViewData.java

private void addTableViewModeCustomize() {
    table_view_mode = (TableLayout) findViewById(R.id.table_view_mode);
    table_view_mode.removeAllViews();/*from   ww w .  j  av a 2  s.c  o m*/

    // Row From
    TableRow row = new TableRow(this);
    TextView txt = new TextView(this);
    txt.setText("From: ");
    txt.setTextColor(Color.parseColor("#000000"));
    row.addView(txt);

    //      Date time = new Date();
    startTime = new Date();
    startTime.setMinutes(startTime.getMinutes() - 1);
    endTime = new Date();

    // Start Time
    SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
    txtStartTime = new TextView(this);
    txtStartTime.setText(formatter.format(startTime) + "");
    txtStartTime.setTextColor(Color.parseColor("#000000"));
    txtStartTime.setBackgroundColor(Color.parseColor("#61a7db"));
    row.addView(txtStartTime);

    txtStartTime.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            new TimePickerDialog(context, startTimeSetListener, dateAndTime.get(Calendar.HOUR_OF_DAY) - 1,
                    dateAndTime.get(Calendar.MINUTE), true).show();
        }
    });

    // Add space
    txt = new TextView(this);
    txt.setText("     ");
    row.addView(txt);

    // Start Date
    formatter = new SimpleDateFormat("dd/MM/yyyy");
    // txtStartDate, txtStartTime
    txtStartDate = new TextView(this);
    txtStartDate.setText(formatter.format(startTime) + "");
    txtStartDate.setTextColor(Color.parseColor("#000000"));
    txtStartDate.setBackgroundColor(Color.parseColor("#61a7db"));
    row.addView(txtStartDate);

    txtStartDate.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            new DatePickerDialog(context, startDateSetListener, dateAndTime.get(Calendar.YEAR),
                    dateAndTime.get(Calendar.MONTH), dateAndTime.get(Calendar.DAY_OF_MONTH)).show();
        }
    });

    table_view_mode.addView(row);

    // Add a space row
    row = new TableRow(this);
    txt = new TextView(this);
    txt.setText("-");
    row.addView(txt);
    table_view_mode.addView(row);

    // Row To
    row = new TableRow(this);
    txt = new TextView(this);
    txt.setText("To");
    txt.setTextColor(Color.parseColor("#000000"));
    row.addView(txt);

    // End Time
    formatter = new SimpleDateFormat("HH:mm:ss");
    txtEndTime = new TextView(this);
    txtEndTime.setText(formatter.format(endTime) + "");
    txtEndTime.setTextColor(Color.parseColor("#000000"));
    txtEndTime.setBackgroundColor(Color.parseColor("#61a7db"));
    row.addView(txtEndTime);

    txtEndTime.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            new TimePickerDialog(context, endTimeSetListener, dateAndTime.get(Calendar.HOUR_OF_DAY),
                    dateAndTime.get(Calendar.MINUTE), true).show();
        }
    });

    // Add space
    txt = new TextView(this);
    txt.setText("     ");
    row.addView(txt);

    // End Date
    formatter = new SimpleDateFormat("dd/MM/yyyy");
    // txtStartDate, txtStartTime
    txtEndDate = new TextView(this);
    txtEndDate.setText(formatter.format(endTime) + "");
    txtEndDate.setTextColor(Color.parseColor("#000000"));
    txtEndDate.setBackgroundColor(Color.parseColor("#61a7db"));
    row.addView(txtEndDate);

    txtEndDate.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            new DatePickerDialog(context, endDateSetListener, dateAndTime.get(Calendar.YEAR),
                    dateAndTime.get(Calendar.MONTH), dateAndTime.get(Calendar.DAY_OF_MONTH)).show();
        }
    });

    table_view_mode.addView(row);

    // Row
    row = new TableRow(this);
    Button detailBtn = new Button(this);
    detailBtn.setTextSize(TEXT_SIZE + 4);
    detailBtn.setText("Detail");
    detailBtn.setTextColor(Color.parseColor("#000000"));
    detailBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    });

    Button plotDataBtn = new Button(this);
    plotDataBtn.setTextSize(TEXT_SIZE + 4);
    plotDataBtn.setText("Plot data");
    plotDataBtn.setTextColor(Color.parseColor("#000000"));
    plotDataBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            viewChart();
        }
    });

    TableRow.LayoutParams params = new TableRow.LayoutParams();
    // params.addRule(TableRow.LayoutParams.FILL_PARENT);
    params.span = 2;

    row.addView(detailBtn, params);
    row.addView(plotDataBtn, params);
    row.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    table_view_mode.addView(row);

}

From source file:ru.adios.budgeter.widgets.DataTableLayout.java

private void insertNoDataRow() {
    final Context context = getContext();
    final TableRow noDataRow = constructRow(context, 1f);
    noDataRow.addView(
            getCenteredRowText(context, getResources().getString(R.string.data_table_no_rows), 1f, false, 1f));
    addView(noDataRow, headerOffset);/*from  www .j  a va2s  . c  om*/
}

From source file:samsungsami.io.example.samiremotecontrol.DeviceActivity.java

/**
 * Fill the device status and info table
 *//*from w  w  w.java 2 s . co m*/
void fillTable() {

    TableRow row;
    TextView t1, t2, t3;
    for (int current = 0; current < fields.size(); current++) {
        row = new TableRow(this);
        t1 = new TextView(this);
        t1.setTextColor(Color.GRAY);
        t2 = new TextView(this);
        t2.setTextColor(Color.BLACK);
        t3 = new TextView(this);
        t3.setTextColor(Color.BLACK);

        t1.setText(fields.get(current));
        t2.setText(values.get(current));
        t3.setText(units.get(current));

        t1.setTextSize(15);
        t2.setTextSize(15);
        t3.setTextSize(15);

        row.addView(t1);

        if (fields.get(current).equals("state")) {
            Switch toggle = new Switch(this);
            toggle.setChecked(values.get(current).toLowerCase().equals("on"));
            toggle.setEnabled(false);
            row.addView(toggle);
        } else
            row.addView(t2);

        row.addView(t3);
        propertiesTableLayout.addView(row, new TableLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        // Adjust the view
        propertiesTableLayout.setColumnStretchable(0, true);
        propertiesTableLayout.setColumnStretchable(1, true);
        propertiesTableLayout.setColumnStretchable(2, true);
    }
}

From source file:tinygsn.gui.android.ActivityViewDataNew.java

private void addTableViewModeLatest() {
    table_view_mode = (TableLayout) findViewById(R.id.table_view_mode);
    // table_view_mode.setLayoutParams(new
    // TableLayout.LayoutParams(LayoutParams.FILL_PARENT,
    // LayoutParams.WRAP_CONTENT));
    table_view_mode.removeAllViews();/*  w ww .  ja  va  2s  . c o  m*/

    TableRow row = new TableRow(this);

    TextView txt = new TextView(this);
    txt.setText("         View ");
    txt.setTextColor(Color.parseColor("#000000"));
    row.addView(txt);

    final EditText editText_numLatest = new EditText(this);
    editText_numLatest.setText("10");
    editText_numLatest.setInputType(InputType.TYPE_CLASS_NUMBER);
    editText_numLatest.requestFocus();
    editText_numLatest.setTextColor(Color.parseColor("#000000"));
    row.addView(editText_numLatest);

    editText_numLatest.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            try {
                numLatest = Integer.parseInt(editText_numLatest.getText().toString());
                loadLatestData();
            } catch (NumberFormatException e) {
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
                alertDialogBuilder.setTitle("Please input a number!");
            }
        }
    });

    txt = new TextView(this);
    txt.setText(" latest values");
    txt.setTextColor(Color.parseColor("#000000"));
    row.addView(txt);

    txt = new TextView(this);
    txt.setText("            ");
    row.addView(txt);
    table_view_mode.addView(row);

    row = new TableRow(this);
    Button detailBtn = new Button(this);
    detailBtn.setText("Detail");

    // detailBtn.setBackground(getResources().getDrawable(R.drawable.info));
    // detailBtn.setWidth(200);
    detailBtn.setTextSize(TEXT_SIZE + 2);
    detailBtn.setTextColor(Color.parseColor("#000000"));
    detailBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialogDetail();
        }
    });

    Button plotDataBtn = new Button(this);
    plotDataBtn.setText("Plot data");
    plotDataBtn.setTextSize(TEXT_SIZE + 2);
    plotDataBtn.setTextColor(Color.parseColor("#000000"));
    // plotDataBtn.setBackground(getResources().getDrawable(R.drawable.chart));

    // LinearLayout.LayoutParams params = plotDataBtn.getLayoutParams();
    // params.width = 50;
    // plotDataBtn.setLayoutParams(params);

    plotDataBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            viewChart();
        }
    });

    TableRow.LayoutParams rowParams = new TableRow.LayoutParams();
    // params.addRule(TableRow.LayoutParams.FILL_PARENT);
    rowParams.span = 2;

    row.addView(detailBtn, rowParams);
    row.addView(plotDataBtn, rowParams);

    // detailBtn.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
    // LayoutParams.WRAP_CONTENT));
    // plotDataBtn.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
    // LayoutParams.WRAP_CONTENT));

    row.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    table_view_mode.addView(row);
}

From source file:com.near.chimerarevo.fragments.PostFragment.java

private void parseTables(Elements tbls) {
    TableLayout tl = new TableLayout(getActivity());
    LayoutParams tl_prms = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    tl_prms.gravity = Gravity.CENTER_HORIZONTAL;
    tl_prms.setMargins(10, 10, 10, 0);/*  w ww.  ja  v  a2 s  . c o  m*/
    tl.setLayoutParams(tl_prms);

    for (Element tbl : tbls) {
        Elements rws = tbl.getElementsByTag("td");
        TableRow row = new TableRow(getActivity());
        for (Element rw : rws) {
            TextView txt = new TextView(getActivity());
            txt.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                    TableRow.LayoutParams.WRAP_CONTENT));
            txt.setText(rw.text());
            row.addView(txt);
        }
        tl.addView(row);
    }
    lay.addView(tl);
}

From source file:tinygsn.gui.android.ActivityViewDataNew.java

private void addTableViewModeCustomize() {
    table_view_mode = (TableLayout) findViewById(R.id.table_view_mode);
    table_view_mode.removeAllViews();/*  ww w.  j  a  v a2s. c  o m*/

    // Row From
    TableRow row = new TableRow(this);
    TextView txt = new TextView(this);
    txt.setText("From: ");
    txt.setTextColor(Color.parseColor("#000000"));
    row.addView(txt);

    // Date time = new Date();
    startTime = new Date();
    startTime.setMinutes(startTime.getMinutes() - 1);
    endTime = new Date();

    // Start Time
    SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
    txtStartTime = new TextView(this);
    txtStartTime.setText(formatter.format(startTime) + "");
    txtStartTime.setTextColor(Color.parseColor("#000000"));
    txtStartTime.setBackgroundColor(Color.parseColor("#8dc63f"));
    row.addView(txtStartTime);

    txtStartTime.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            new TimePickerDialog(context, startTimeSetListener, dateAndTime.get(Calendar.HOUR_OF_DAY) - 1,
                    dateAndTime.get(Calendar.MINUTE), true).show();
        }
    });

    // Add space
    txt = new TextView(this);
    txt.setText("     ");
    row.addView(txt);

    // Start Date
    formatter = new SimpleDateFormat("dd/MM/yyyy");
    // txtStartDate, txtStartTime
    txtStartDate = new TextView(this);
    txtStartDate.setText(formatter.format(startTime) + "");
    txtStartDate.setTextColor(Color.parseColor("#000000"));
    txtStartDate.setBackgroundColor(Color.parseColor("#8dc63f"));
    row.addView(txtStartDate);

    txtStartDate.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            new DatePickerDialog(context, startDateSetListener, dateAndTime.get(Calendar.YEAR),
                    dateAndTime.get(Calendar.MONTH), dateAndTime.get(Calendar.DAY_OF_MONTH)).show();
        }
    });

    table_view_mode.addView(row);

    // Add a space row
    row = new TableRow(this);
    txt = new TextView(this);
    txt.setText("-");
    row.addView(txt);
    table_view_mode.addView(row);

    // Row To
    row = new TableRow(this);
    txt = new TextView(this);
    txt.setText("To");
    txt.setTextColor(Color.parseColor("#000000"));
    row.addView(txt);

    // End Time
    formatter = new SimpleDateFormat("HH:mm:ss");
    txtEndTime = new TextView(this);
    txtEndTime.setText(formatter.format(endTime) + "");
    txtEndTime.setTextColor(Color.parseColor("#000000"));
    txtEndTime.setBackgroundColor(Color.parseColor("#8dc63f"));
    row.addView(txtEndTime);

    txtEndTime.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            new TimePickerDialog(context, endTimeSetListener, dateAndTime.get(Calendar.HOUR_OF_DAY),
                    dateAndTime.get(Calendar.MINUTE), true).show();
        }
    });

    // Add space
    txt = new TextView(this);
    txt.setText("     ");
    row.addView(txt);

    // End Date
    formatter = new SimpleDateFormat("dd/MM/yyyy");
    // txtStartDate, txtStartTime
    txtEndDate = new TextView(this);
    txtEndDate.setText(formatter.format(endTime) + "");
    txtEndDate.setTextColor(Color.parseColor("#000000"));
    txtEndDate.setBackgroundColor(Color.parseColor("#8dc63f"));
    row.addView(txtEndDate);

    txtEndDate.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            new DatePickerDialog(context, endDateSetListener, dateAndTime.get(Calendar.YEAR),
                    dateAndTime.get(Calendar.MONTH), dateAndTime.get(Calendar.DAY_OF_MONTH)).show();
        }
    });

    table_view_mode.addView(row);

    // Row
    row = new TableRow(this);
    Button detailBtn = new Button(this);
    detailBtn.setTextSize(TEXT_SIZE + 2);
    detailBtn.setText("Detail");
    detailBtn.setTextColor(Color.parseColor("#000000"));
    detailBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    });

    Button plotDataBtn = new Button(this);
    plotDataBtn.setTextSize(TEXT_SIZE + 2);
    plotDataBtn.setText("Plot data");
    plotDataBtn.setTextColor(Color.parseColor("#000000"));
    plotDataBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            viewChart();
        }
    });

    TableRow.LayoutParams params = new TableRow.LayoutParams();
    // params.addRule(TableRow.LayoutParams.FILL_PARENT);
    params.span = 2;

    row.addView(detailBtn, params);
    row.addView(plotDataBtn, params);
    row.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    table_view_mode.addView(row);

}

From source file:de.eidottermihi.rpicheck.activity.MainActivity.java

private View createProcessRow(ProcessBean processBean) {
    final TableRow tempRow = new TableRow(this);
    tempRow.addView(createTextView(processBean.getpId() + ""));
    tempRow.addView(createTextView(processBean.getTty()));
    tempRow.addView(createTextView(processBean.getCpuTime()));
    tempRow.addView(createTextView(processBean.getCommand()));
    return tempRow;
}