Example usage for android.widget TableRow TableRow

List of usage examples for android.widget TableRow TableRow

Introduction

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

Prototype

public TableRow(Context context) 

Source Link

Document

Creates a new TableRow for the given context.

Usage

From source file:com.cybrosys.scientific.EventListener.java

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
@Override//from  w w  w  .jav  a 2s  .c o  m
public void onClick(View vwView) {
    vibrate();
    ctx = PalmCalcActivity.ctx;
    int id = vwView.getId();
    ScientificActivity.txtvShift.setText("");
    switch (id) {

    case R.id.buttonDel:
        mHandler.onDelete();
        break;
    case R.id.button3:
        if (inShift == 0)
            mHandler.insert("3");
        else {
            mHandler.insert(",");
            inShift = 0;
        }
        break;
    case R.id.buttonDot:
        if (inShift == 0)
            mHandler.insert(".");
        else {
            showD();
            inShift = 0;
        }
        break;
    case R.id.buttonAC:
        mHandler.onClear();
        break;

    case R.id.ButtonEqual:
        String strDisplayEq = mHandler.getDisplayText();
        if (!strDisplayEq.equalsIgnoreCase(""))
            mHandler.onEnter();
        break;

    case R.id.ButtonAns:
        if (inShift == 0)
            mHandler.onShow();
        else {
            showHistory();
            inShift = 0;
        }
        break;
    case R.id.buttonDeg:
        mHandler.onDegChange();
        break;
    case R.id.buttonAlt:

        if (inShift == 0) {
            String[] strMode = new String[] { "Floatpt", "FIX", "SCI" };
            int inSizeM = 3;

            LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            vwLayout = inflater.inflate(R.layout.pop_history,
                    (ViewGroup) ((Activity) ctx).findViewById(R.id.popup_element));
            TextView txtvHeaderPop = (TextView) vwLayout.findViewById(R.id.txtvHeaderPop);
            txtvHeaderPop.setText("MODE");
            popmW1 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight,
                    true);
            popmW1.setBackgroundDrawable(new BitmapDrawable());
            popmW1.setOutsideTouchable(true);
            popmW1.showAtLocation(vwLayout, Gravity.CENTER, 0, 0);
            tblltTable = (TableLayout) vwLayout.findViewById(R.id.tablelay);
            ImageButton btnCancel = (ImageButton) vwLayout.findViewById(R.id.butcancelmain);
            btnCancel.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    popmW1.dismiss();

                }
            });
            txtvHistory = new TextView[inSizeM];
            btnHistory = new Button[inSizeM];
            tblrRowL = new TableRow[inSizeM];
            TableRow.LayoutParams buttonParams = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,
                    TableRow.LayoutParams.WRAP_CONTENT, 1f);
            TableRow.LayoutParams textParams = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,
                    TableRow.LayoutParams.WRAP_CONTENT, .1f);
            int inJ = 0;
            for (int inI = 0; inI < inSizeM; inI++) {
                btnHistory[inJ] = new Button(ctx);
                txtvHistory[inJ] = new TextView(ctx);
                txtvHistory[inJ].setText("" + (inJ + 1));
                txtvHistory[inJ].setLayoutParams(textParams);
                btnHistory[inJ].setText(strMode[inI]);
                txtvHistory[inJ].setGravity(Gravity.CENTER);
                txtvHistory[inJ]
                        .setTextColor(ScientificActivity.ctx.getResources().getColor(R.color.HistColor));
                btnHistory[inJ].setTextColor(Color.WHITE);
                btnHistory[inJ].setGravity(Gravity.LEFT);
                btnHistory[inJ].setLayoutParams(buttonParams);
                btnHistory[inJ].setBackgroundDrawable(ctx.getResources().getDrawable(R.drawable.button_effect));
                tblrRowL[inJ] = new TableRow(ctx);
                tblrRowL[inJ].addView(txtvHistory[inJ]);
                tblrRowL[inJ].addView(btnHistory[inJ]);
                tblltTable.addView(tblrRowL[inJ]);
                final int inK = inJ;
                btnHistory[inK].setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        // etxt.setText(btns[inK].getText().toString());
                        ScientificActivity.txtvFSE.setText(btnHistory[inK].getText().toString());
                        popmW1.dismiss();
                    }
                });

                inJ++;

            }

        } else {
            setFSE();
            inShift = 0;
        }
        mHandler.onFSEChange();
        break;
    case R.id.buttonShift:
        if (inShift == 0) {
            inShift = 1;
            mHandler.onShiftPress();
        } else
            inShift = 0;

        break;
    case R.id.buttonHyp:
        if (inHyp == 0) {
            inHyp = 1;
            mHandler.onHypPress();
        } else {
            inHyp = 0;
            ScientificActivity.txtvHyp.setText("");
        }
        break;
    case R.id.buttonMS:
        mHandler.onEnter();
        String strDisplay = mHandler.getDisplayText();
        if (inShift == 0) {

            if (isValidNumber(strDisplay)) {

                PreferenceClass.setMyStringPref(ctx, strDisplay);
                Toast.makeText(ctx, "Memory Saved!", Toast.LENGTH_SHORT).show();
                mHandler.onClear();
            } else
                Toast.makeText(ctx, "Save Failed!", Toast.LENGTH_SHORT).show();

        } else {
            Memstore();
        }

        break;
    case R.id.buttonMR:
        if (inShift == 0) {
            String strPref = PreferenceClass.getMyStringPref(ctx);
            if (!strPref.equalsIgnoreCase("")) {
                mHandler.insert(strPref);
            } else
                Toast.makeText(ctx, "Empty", Toast.LENGTH_SHORT).show();
        } else {
            Memread();
            inShift = 0;

        }
        break;
    case R.id.buttonMp:
        mHandler.onEnter();
        String strDisplay2 = mHandler.getDisplayText();
        if (isValidNumber(strDisplay2)) {
            String strPref2 = PreferenceClass.getMyStringPref(ctx);
            if (!strPref2.equalsIgnoreCase("")) {
                if (inShift == 0) {
                    try {
                        PreferenceClass.setMyStringPref(ctx, "" + mSymbols.eval(strPref2 + "+" + strDisplay2));
                        mHandler.onClear();
                    } catch (SyntaxException e) {

                        e.printStackTrace();
                    }
                    Toast.makeText(ctx, "Value added", Toast.LENGTH_SHORT).show();
                } else {
                    Memplus();

                    inShift = 0;
                }
            }
        }
        break;

    default:
        if (vwView instanceof Button) {
            String strText = ((Button) vwView).getTag().toString();
            if (strText.contains(",")) {
                int inInComa = strText.lastIndexOf(",");
                if (inShift == 1) {
                    strText = strText.substring(inInComa + 1, strText.length());
                    inShift = 0;
                } else {
                    strText = strText.substring(0, inInComa);
                }

            }

            if (inHyp == 1) {

                if (strText.contains("sin(")) {
                    strText = strText.replace("sin(", "sinh(");
                }
                if (strText.contains("cos(")) {
                    strText = strText.replace("cos(", "cosh(");
                }
                if (strText.contains("tan(")) {
                    strText = strText.replace("tan(", "tanh(");
                }
                ScientificActivity.txtvHyp.setText("");
                inHyp = 0;
            }
            mHandler.insert(strText);

        }
    }
}

From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java

private void addButton(final String senderName, String myEmail, boolean somebodyAnswered, boolean canEdit,
        TableLayout tableLayout, final ButtonTO button) {
    TableRow row = new TableRow(this);
    tableLayout.addView(row);/*from ww  w.j a  v a2s.c om*/
    row.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.WRAP_CONTENT, 1));

    // XXX: inconsistent margin between 2 rows

    final Button buttonView = new Button(this);
    buttonView.setMinWidth(UIUtils.convertDipToPixels(this, 100));
    buttonView.setText(button.caption);
    buttonView.setTextColor(getResources().getColor(android.R.color.primary_text_dark));
    if (somebodyAnswered)
        buttonView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
    else {
        buttonView.setWidth(mDisplayWidth - UIUtils.convertDipToPixels(this, 12));
    }
    buttonView.setTextSize(19);
    row.addView(buttonView);

    final LinearLayout container = (LinearLayout) getLayoutInflater().inflate(R.layout.message_button_detail,
            null);
    container.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);

    boolean buttonSelectedByMe = false;
    for (MemberStatusTO status : mCurrentMessage.members) {
        if ((status.status & MessagingPlugin.STATUS_ACKED) == MessagingPlugin.STATUS_ACKED
                && ((button.id == null && status.button_id == null)
                        || (button.id != null && button.id.equals(status.button_id)))) {

            getLayoutInflater().inflate(R.layout.avatar, container);
            ImageView avatar = (ImageView) container.getChildAt(container.getChildCount() - 1);

            setAvatar(avatar, status.member);
            if (status.member.equals(myEmail))
                buttonSelectedByMe = true;

            int dp42 = UIUtils.convertDipToPixels(this, 42);
            int dp2 = UIUtils.convertDipToPixels(this, 1);
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) avatar.getLayoutParams();
            lp.setMargins(0, dp2, 0, 0);
            lp.width = dp42;
            lp.height = dp42;
        }
    }

    row.addView(container);

    boolean hasAction = button.action != null && !"".equals(button.action);
    final boolean buttonIsEnabled = canEdit
            && (mCurrentMessage.form != null || !buttonSelectedByMe || hasAction);
    buttonView.setEnabled(buttonIsEnabled);

    int color;
    if (button.id == null || mCurrentMessage.form != null && Message.POSITIVE.equals(button.id)) {
        color = buttonIsEnabled ? Message.GREEN_BUTTON_COLOR : Message.GREENGRAY_BUTTON_COLOR;
    } else if (mCurrentMessage.form != null && Message.NEGATIVE.equals(button.id)) {
        color = buttonIsEnabled ? Message.RED_BUTTON_COLOR : Message.REDGRAY_BUTTON_COLOR;
    } else {
        color = buttonIsEnabled ? Message.BLUE_BUTTON_COLOR : Message.BLUEGRAY_BUTTON_COLOR;
    }
    buttonView.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY);

    buttonView.setOnClickListener(new SafeViewOnClickListener() {

        @Override
        public void safeOnClick(View v) {
            T.UI();
            executeButtonClick(button, container, true);
        }
    });

    final HorizontalScrollView scroller = (HorizontalScrollView) findViewById(R.id.button_scroller);
    scroller.post(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            scroller.fullScroll(ScrollView.FOCUS_RIGHT);
        }
    });
}

From source file:org.smilec.smile.student.CourseList.java

private void createScoreTable(Vector<Integer> _myscore, String username) {

    int num_right = countrightquestion(_myscore);
    int total_question = LAST_SCENE_NUM;

    TableLayout tl = (TableLayout) findViewById(R.id.tableLayoutSeeR);
    TextView text1 = (TextView) findViewById(R.id.Header01);
    text1.setText(getString(R.string.name) + ": " + username);
    TextView text2 = (TextView) findViewById(R.id.Header11);
    text2.setText(getString(R.string.t_score) + ":" + num_right + "/" + total_question);

    for (int i = 0; i < _myscore.size(); i++) {
        TableRow tr = new TableRow(getApplicationContext());
        tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT));
        int number = 0;
        number = i + 1;//  w ww.j a  v  a2  s  .  co m
        int score = _myscore.get(i);

        Button b = new Button(getApplicationContext());
        b.setText("(" + number + ")");
        b.setTextSize(resultSize1);
        // b.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
        TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT);
        params.setMargins(returnPixels(30.0f), 0, returnPixels(30.0f), 0);
        b.setLayoutParams(params);
        b.setOnClickListener(new MyButtonListener(number));

        /* Add Button to row. */
        tr.addView(b);
        TextView text = new TextView(getApplicationContext());

        if (score == 1) { // right
            text.setText("0");
        } else { // wrong
            text.setText("X");
        }
        text.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT));
        text.setTextColor(Color.BLACK);
        text.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
        text.setTextSize(resultSize2);
        tr.addView(text);

        //tr.setBackgroundResource(R.drawable.sf_gradient_03);
        tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,
                TableLayout.LayoutParams.WRAP_CONTENT));

    }

    return;
}

From source file:com.vonglasow.michael.satstat.MainActivity.java

protected static void showCellCdma(CellTowerCdma cell) {
    TableRow row = new TableRow(rilCdmaCells.getContext());
    row.setWeightSum(26);/*from   w  w  w . ja v  a 2  s  .  co  m*/

    TextView newType = new TextView(rilCdmaCells.getContext());
    newType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newType.setTextAppearance(rilCdmaCells.getContext(), android.R.style.TextAppearance_Medium);
    newType.setTextColor(
            rilCdmaCells.getContext().getResources().getColor(getColorFromGeneration(cell.getGeneration())));
    newType.setText(rilCdmaCells.getContext().getResources().getString(R.string.smallDot));
    row.addView(newType);

    TextView newSid = new TextView(rilCdmaCells.getContext());
    newSid.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 6));
    newSid.setTextAppearance(rilCdmaCells.getContext(), android.R.style.TextAppearance_Medium);
    newSid.setText(formatCellData(rilCdmaCells.getContext(), null, cell.getSid()));
    row.addView(newSid);

    TextView newNid = new TextView(rilCdmaCells.getContext());
    newNid.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 5));
    newNid.setTextAppearance(rilCdmaCells.getContext(), android.R.style.TextAppearance_Medium);
    newNid.setText(formatCellData(rilCdmaCells.getContext(), null, cell.getNid()));
    row.addView(newNid);

    TextView newBsid = new TextView(rilCdmaCells.getContext());
    newBsid.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 9));
    newBsid.setTextAppearance(rilCdmaCells.getContext(), android.R.style.TextAppearance_Medium);
    newBsid.setText(formatCellData(rilCdmaCells.getContext(), null, cell.getBsid()));
    row.addView(newBsid);

    TextView newDbm = new TextView(rilCdmaCells.getContext());
    newDbm.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 4));
    newDbm.setTextAppearance(rilCdmaCells.getContext(), android.R.style.TextAppearance_Medium);
    newDbm.setText(formatCellDbm(rilCdmaCells.getContext(), null, cell.getDbm()));
    row.addView(newDbm);

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

From source file:com.vonglasow.michael.satstat.MainActivity.java

protected static void showCellGsm(CellTowerGsm cell) {
    TableRow row = new TableRow(rilCells.getContext());
    row.setWeightSum(29);/* www. j  av  a 2s  .c o  m*/

    TextView newType = new TextView(rilCells.getContext());
    newType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newType.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newType.setTextColor(
            rilCells.getContext().getResources().getColor(getColorFromGeneration(cell.getGeneration())));
    newType.setText(rilCells.getContext().getResources().getString(R.string.smallDot));
    row.addView(newType);

    TextView newMcc = new TextView(rilCells.getContext());
    newMcc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMcc.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newMcc.setText(formatCellData(rilCells.getContext(), "%03d", cell.getMcc()));
    row.addView(newMcc);

    TextView newMnc = new TextView(rilCells.getContext());
    newMnc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMnc.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newMnc.setText(formatCellData(rilCells.getContext(), "%02d", cell.getMnc()));
    row.addView(newMnc);

    TextView newLac = new TextView(rilCells.getContext());
    newLac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 5));
    newLac.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newLac.setText(formatCellData(rilCells.getContext(), null, cell.getLac()));
    row.addView(newLac);

    TextView newCid = new TextView(rilCells.getContext());
    newCid.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 9));
    newCid.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newCid.setText(formatCellData(rilCells.getContext(), null, cell.getCid()));
    row.addView(newCid);

    TextView newPsc = new TextView(rilCells.getContext());
    newPsc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newPsc.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newPsc.setText(formatCellData(rilCells.getContext(), null, cell.getPsc()));
    row.addView(newPsc);

    TextView newDbm = new TextView(rilCells.getContext());
    newDbm.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 4));
    newDbm.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newDbm.setText(formatCellDbm(rilCells.getContext(), null, cell.getDbm()));
    row.addView(newDbm);

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

From source file:com.vonglasow.michael.satstat.MainActivity.java

protected static void showCellLte(CellTowerLte cell) {
    TableRow row = new TableRow(rilLteCells.getContext());
    row.setWeightSum(29);/*w  ww  .j a v a  2s . c o  m*/

    TextView newType = new TextView(rilLteCells.getContext());
    newType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newType.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newType.setTextColor(
            rilLteCells.getContext().getResources().getColor(getColorFromGeneration(cell.getGeneration())));
    newType.setText(rilLteCells.getContext().getResources().getString(R.string.smallDot));
    row.addView(newType);

    TextView newMcc = new TextView(rilLteCells.getContext());
    newMcc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMcc.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newMcc.setText(formatCellData(rilLteCells.getContext(), "%03d", cell.getMcc()));
    row.addView(newMcc);

    TextView newMnc = new TextView(rilLteCells.getContext());
    newMnc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMnc.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newMnc.setText(formatCellData(rilLteCells.getContext(), "%02d", cell.getMnc()));
    row.addView(newMnc);

    TextView newTac = new TextView(rilLteCells.getContext());
    newTac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 5));
    newTac.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newTac.setText(formatCellData(rilLteCells.getContext(), null, cell.getTac()));
    row.addView(newTac);

    TextView newCi = new TextView(rilLteCells.getContext());
    newCi.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 9));
    newCi.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newCi.setText(formatCellData(rilLteCells.getContext(), null, cell.getCi()));
    row.addView(newCi);

    TextView newPci = new TextView(rilLteCells.getContext());
    newPci.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newPci.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newPci.setText(formatCellData(rilLteCells.getContext(), null, cell.getPci()));
    row.addView(newPci);

    TextView newDbm = new TextView(rilLteCells.getContext());
    newDbm.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 4));
    newDbm.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newDbm.setText(formatCellDbm(rilLteCells.getContext(), null, cell.getDbm()));
    row.addView(newDbm);

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