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:org.mklab.mikity.android.editor.GroupEditor.java

private void createCoordinateParameterBoxes(final View view) {
    final TableLayout parameters = ((TableLayout) view.findViewById(R.id.coordinate_parameters));
    parameters.removeAllViews();//from w  w  w  . j  a v  a2  s.c o  m
    parameters.setStretchAllColumns(true);

    final TableRow head = new TableRow(getContext());
    final TextView name = new TextView(getContext());
    name.setText(R.string.name);
    name.setTextColor(Color.BLACK);
    final TextView value = new TextView(getContext());
    value.setText(R.string.value);
    value.setTextColor(Color.BLACK);
    head.addView(name);
    head.addView(value);
    parameters.addView(head);

    createCoordinateTranslationBoxes(parameters);
    createCoordinateRotationBoxes(parameters);
}

From source file:com.acceleratedio.pac_n_zoom.SaveAnmActivity.java

private void dsply_tags() {

    TableLayout tbl_tag_lo = (TableLayout) findViewById(R.id.tl_tgs);
    int tag_mbr = 0;
    int tag_nmbr = fil_tags.length;
    String lst_str = "";
    int row_mbr;//from   ww w.ja va2 s.  c  om

    tbl_tag_lo.setAlpha(185);

    // - Find the search string
    srch_str = srch_str.trim();
    boolean flg_srch_tags = !srch_str.equals("");

    if (flg_srch_tags) {

        String[] srch_ary = srch_str.split("\\s* \\s*");
        srch_str = srch_ary[srch_ary.length - 1].toLowerCase();
    }

    // - Remove any current rows
    int row_nmbr = tbl_tag_lo.getChildCount();

    if (row_nmbr > 0)
        tbl_tag_lo.removeAllViews();

    for (row_mbr = 0; tag_mbr < tag_nmbr; row_mbr++) {

        TableRow tableRow = new TableRow(this);
        tableRow.setGravity(Gravity.CENTER);

        tableRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
                TableLayout.LayoutParams.MATCH_PARENT, 1.0f));

        int clm_mbr;

        for (clm_mbr = 0; clm_mbr < 3; clm_mbr++) {

            Button btnTag = new Button(this);

            while (tag_mbr < tag_nmbr
                    && (fil_tags[tag_mbr].equals("") || fil_tags[tag_mbr].equalsIgnoreCase(lst_str)
                            || flg_srch_tags && !fil_tags[tag_mbr].toLowerCase().startsWith(srch_str))) {

                lst_str = fil_tags[tag_mbr];
                tag_mbr++;
            }

            if (tag_mbr >= tag_nmbr)
                break;

            lst_str = fil_tags[tag_mbr];
            btnTag.setText(fil_tags[tag_mbr++]);
            btnTag.setOnClickListener(this);

            btnTag.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
                    TableRow.LayoutParams.MATCH_PARENT));

            tableRow.addView(btnTag);
        }

        if (clm_mbr > 0)
            tbl_tag_lo.addView(tableRow);
    }
}

From source file:com.google.reviewit.AddReviewerFragment.java

private void displayCCs(Change change) {
    TableLayout tl = (TableLayout) v(R.id.reviewerTable);
    Collection<AccountInfo> ccs = change.ccs();
    if (!ccs.isEmpty()) {
        TableRow tr = new TableRow(getContext());
        tr.setLayoutParams(matchAndWrapTableRowLayout());
        TextView ccsTitle = new TextView(getContext());
        TableRow.LayoutParams params = wrapTableRowLayout(2);
        params.bottomMargin = widgetUtil.dpToPx(3);
        ccsTitle.setLayoutParams(params);
        ccsTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
        ccsTitle.setText(getString(R.string.ccs));
        tr.addView(ccsTitle);/*from w  w w  .  j a va 2s  . c  o  m*/
        tl.addView(tr, matchAndWrapTableLayout());
        for (AccountInfo cc : ccs) {
            addReviewerRow(tl, cc);
        }
    }
}

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 w  w  w  . j a v  a 2 s  .co  m*/
    headerRow.addView(linesHeaderText);
    headerRow.addView(dateHeaderText);
    return headerRow;
}

From source file:org.mklab.mikity.android.editor.GroupEditor.java

private void createAnimationParameterBoxes(final View view) {
    final TableLayout parameters = ((TableLayout) view.findViewById(R.id.animation_parameters));
    parameters.removeAllViews();//w w  w . j  a va2s.  c  o m
    parameters.setStretchAllColumns(true);

    final TableRow head = new TableRow(getContext());
    parameters.addView(head);

    final TextView name = new TextView(getContext());
    name.setText(R.string.name);
    name.setTextColor(Color.BLACK);
    head.addView(name);

    final TextView id = new TextView(getContext());
    id.setText(R.string.id);
    id.setTextColor(Color.BLACK);
    head.addView(id);

    final TextView number = new TextView(getContext());
    number.setText(R.string.number);
    number.setTextColor(Color.BLACK);
    head.addView(number);

    createAnimationTranslationBoxes(parameters);
    createAnimationRotationBoxes(parameters);

    setAnimationInDialog();
}

From source file:com.woofer.activity.personHomeActivity.java

public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.LEFT;
    layoutParams.leftMargin = 30;//from www. j a v  a2s .  c om
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 30; i++) {

        TableRow tableRow = new TableRow(this);
        TextView textView7 = new TextView(this);
        textView7.setText("" + i);
        textView7.setTextSize(18);
        textView7.setTextColor(Color.rgb(0, 0, 0));

        textView7.setPadding(15, 0, 15, 0);
        tableRow.addView(textView7, layoutParams);
        tableRow.setBackgroundColor(Color.WHITE);

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);

        TableRow tableRow1 = new TableRow(this);
        TextView textView1 = new TextView(this);
        textView1.setText("Test pull down scrollvsfadasdsadsasadsadsadsadsadasdsadasdasdsadsaddasdiew " + i);
        textView1.setTextSize(16);
        textView1.setPadding(15, 0, 15, 15);
        tableRow1.addView(textView1, layoutParams);
        tableRow1.setBackgroundColor(Color.WHITE);

        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });
        mMainLayout.addView(tableRow1);

        //            TableRow tableRow2 = new TableRow(this);
        //            //tableRow2.addView(textView2, layoutParams);
        //            ImageView imageView = new ImageView(this);
        //            imageView.setImageResource(R.drawable.icon_reply_t);
        //            imageView.setScaleX((float) a);
        //            imageView.setScaleY((float) a);
        //            imageView.setPadding(0, 0, 0, 0);
        //
        //            ImageView imageView1 = new ImageView(this);
        //            imageView1.setImageResource(R.drawable.icon_thumb_t);
        //            imageView1.setScaleX((float) a);
        //            imageView1.setScaleY((float) a);
        //            imageView1.setPadding(0, 0, 0, 0);
        //
        //
        //            //tableRow2.addView(imageView);
        //            tableRow2.addView(imageView1);
        //            mMainLayout.addView(tableRow2);
        TableLayout mytable = (TableLayout) findViewById(R.id.degital_textTL);
        int numberOfRow = 1;
        int numberOfColumn = 12;
        int cellDimension = 24;
        int cellPadding = 200;
        for (int row = 0; row < numberOfRow; row++) {
            tableRow = new TableRow(this);
            //tableRow.setLayoutParams(new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT));
            tableRow.setLayoutParams(new TableLayout.LayoutParams(
                    (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));

            for (int column = 0; column < numberOfColumn; column++) {
                if (column % 3 == 0) {
                    TextView textView = new TextView(this);
                    textView.setTextSize(20);
                    textView.setText("   ");
                    tableRow.addView(textView);
                }
                if (column % 3 == 1) {
                    if (column == 1) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_eye_t);
                        tableRow.addView(imageView);
                    }
                    if (column == 4) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_thumb_t);
                        tableRow.addView(imageView);
                    }
                    if (column == 7) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_reply_t);
                        tableRow.addView(imageView);
                    }
                    if (column == 10) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_pencil_t);
                        tableRow.addView(imageView);
                    }
                }
                if (column % 3 == 2) {
                    if (column == 2) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                    if (column == 5) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                    if (column == 8) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                    if (column == 11) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                }

            }
            mytable.addView(tableRow, new TableLayout.LayoutParams(
                    (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));
            //mytable.addView(tableRow,new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT));
        }

    }
}

From source file:com.example.hllut.app.Deprecated.MainActivity.java

/**
 * fill the "liters of petrol" textView, as well as drawing the petrol barrels
 *///ww w  .  j a  v a 2  s. c om
private void drawPetrol() {
    //TODO use the bundle
    float litersOfPetrol = (TOTAL_CO2 / CO2_PER_LITRE_PETROL);

    TextView tv = (TextView) findViewById(R.id.litersTextView);
    tv.setText("Burning " + String.format("%.2f", litersOfPetrol) + " liters of petrol");

    TableLayout layout = (TableLayout) findViewById(R.id.petrolContainer);

    TableRow newRow = new TableRow(this);
    LinearLayout linLay = new LinearLayout(this);

    linLay.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT, 1f));

    newRow.setLayoutParams(
            new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
    newRow.setPadding(10, 10, 10, 10);

    for (int i = 1; i < (int) litersOfPetrol + 1; i++) { //
        // TODO: To many images fuck up formatting
        // Create images
        ImageView im = new ImageView(this);
        im.setImageResource(R.drawable.oil_barrel);
        im.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));

        //barrells per row = 7
        if (i % 7 == 0) {
            // if you have gone 7 laps
            // print what you have
            linLay.addView(im);
            newRow.addView(linLay,
                    new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));

            layout.addView(newRow, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,
                    TableLayout.LayoutParams.WRAP_CONTENT));

            newRow = new TableRow(this);
            linLay = new LinearLayout(this);

            linLay.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT, 1f));

            newRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                    TableRow.LayoutParams.WRAP_CONTENT));
            newRow.setPadding(10, 10, 10, 10);
        } else {
            linLay.addView(im);
        }

    }

    newRow.addView(linLay, new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));

    layout.addView(newRow, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.WRAP_CONTENT));
}

From source file:nl.openkvk.MainActivity.java

private void print(TableLayout tl, String l, String v) {
    if (v != null) {
        TextView v1 = new TextView(this);
        v1.setText(l);/*from w w  w  .  ja  va2s .co  m*/
        TextView v2 = new TextView(this);
        v2.setText(v.toString());
        TableRow tr = new TableRow(this);
        tr.addView(v1);
        tr.addView(new TextView(this));
        tr.addView(v2);
        tl.addView(tr);
    }
}

From source file:com.google.reviewit.AddReviewerFragment.java

private void addReviewerRow(TableLayout tl, AccountInfo reviewer) {
    TableRow tr = new TableRow(getContext());
    tr.setLayoutParams(matchAndWrapTableRowLayout());
    ImageView avatar = new ImageView(getContext());
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(widgetUtil.dpToPx(20),
            widgetUtil.dpToPx(20));/*from w  w  w  .  j a v  a 2  s . co  m*/
    layoutParams.setMargins(0, 0, widgetUtil.dpToPx(5), widgetUtil.dpToPx(2));
    avatar.setLayoutParams(layoutParams);

    WidgetUtil.displayAvatar(getApp(), reviewer, avatar);
    tr.addView(avatar);
    TextView reviewerName = new TextView(getContext());
    reviewerName.setLayoutParams(wrapTableRowLayout());
    reviewerName.setText(FormatUtil.format(reviewer));
    tr.addView(reviewerName);
    tl.addView(tr, matchAndWrapTableLayout());
}

From source file:com.ninetwozero.battlelog.fragments.PlatoonStatsFragment.java

public void showStats(PlatoonInformation pi) {

    // Get the activity
    Activity activity = getActivity();// w w w. ja v a  2  s .  c o m

    Log.d(Constants.DEBUG_TAG, "pi => " + pi);
    Log.d(Constants.DEBUG_TAG, "activity => " + activity);

    if (activity == null) {
        return;
    }

    // Let's see what we can do
    platoonInformation = pi;
    PlatoonStats pd = platoonInformation.getStats();

    // Let's start drawing the... layout
    ((TextView) activity.findViewById(R.id.text_name_platoon_tab2)).setText(

            platoonInformation.getName() + " [" + platoonInformation.getTag() + "]"

    );

    // Do we have it??
    if (pd == null) {
        return;
    }

    // Are they null?
    if (wrapGeneral == null) {

        // General ones
        wrapGeneral = (RelativeLayout) activity.findViewById(R.id.wrap_general);

        // Kits & vehicles
        wrapScore = (RelativeLayout) activity.findViewById(R.id.wrap_score);
        wrapSPM = (RelativeLayout) activity.findViewById(R.id.wrap_spm);
        wrapTime = (RelativeLayout) activity.findViewById(R.id.wrap_time);
        tableScores = (TableLayout) wrapScore.findViewById(R.id.tbl_stats);
        tableSPM = (TableLayout) wrapSPM.findViewById(R.id.tbl_stats);
        tableTime = (TableLayout) wrapTime.findViewById(R.id.tbl_stats);

        // Top list
        wrapTopList = (RelativeLayout) activity.findViewById(R.id.wrap_toplist);
        tableTopList = (TableLayout) wrapTopList.findViewById(R.id.tbl_stats);

    } else {

        tableScores.removeAllViews();
        tableSPM.removeAllViews();
        tableTime.removeAllViews();
        tableTopList.removeAllViews();

    }

    // Let's grab the different data
    PlatoonStatsItem generalSPM = pd.getGlobalTop().get(0);
    PlatoonStatsItem generalKDR = pd.getGlobalTop().get(1);
    PlatoonStatsItem generalRank = pd.getGlobalTop().get(2);

    // Set the general stats
    ((TextView) wrapGeneral.findViewById(R.id.text_average_spm)).setText(generalSPM.getAvg() + "");
    ((TextView) wrapGeneral.findViewById(R.id.text_max_spm)).setText(generalSPM.getMax() + "");
    ((TextView) wrapGeneral.findViewById(R.id.text_mid_spm)).setText(generalSPM.getMid() + "");
    ((TextView) wrapGeneral.findViewById(R.id.text_min_spm)).setText(generalSPM.getMin() + "");
    ((TextView) wrapGeneral.findViewById(R.id.text_average_rank)).setText(generalRank.getAvg() + "");
    ((TextView) wrapGeneral.findViewById(R.id.text_max_rank)).setText(generalRank.getMax() + "");
    ((TextView) wrapGeneral.findViewById(R.id.text_mid_rank)).setText(generalRank.getMid() + "");
    ((TextView) wrapGeneral.findViewById(R.id.text_min_rank)).setText(generalRank.getMin() + "");
    ((TextView) wrapGeneral.findViewById(R.id.text_average_kdr)).setText(generalKDR.getDAvg() + "");
    ((TextView) wrapGeneral.findViewById(R.id.text_max_kdr)).setText(generalKDR.getDMax() + "");
    ((TextView) wrapGeneral.findViewById(R.id.text_mid_kdr)).setText(generalKDR.getDMid() + "");
    ((TextView) wrapGeneral.findViewById(R.id.text_min_kdr)).setText(generalKDR.getDMin() + "");

    // Top Players
    List<PlatoonTopStatsItem> topStats = pd.getTopPlayers();
    PlatoonTopStatsItem tempTopStats = null;

    // Loop over them, *one* by *one*
    int numCols = 2;
    for (int i = 0, max = topStats.size(); i < max; i++) {

        // Oh well, couldn't quite cache it could we?
        cacheView = (RelativeLayout) layoutInflater.inflate(R.layout.grid_item_platoon_top_stats, null);

        // Add the new TableRow
        if (cacheTableRow == null || (i % numCols) == 0) {

            tableTopList.addView(cacheTableRow = new TableRow(context));
            cacheTableRow.setLayoutParams(

                    new TableRow.LayoutParams(

                            TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT

                    )

            );

        }

        // Add the *layout* into the TableRow
        cacheTableRow.addView(cacheView);

        // Grab *this* item
        tempTopStats = topStats.get(i);

        // Say cheese... (mister Bitmap)
        if (tempTopStats.getProfile() != null) {

            ((ImageView) cacheView.findViewById(R.id.image_avatar)).setImageBitmap(

                    BitmapFactory.decodeFile(

                            PublicUtils.getCachePath(context) + tempTopStats.getProfile().getGravatarHash()
                                    + ".png"

                    )

            );

        } else {

            ((ImageView) cacheView.findViewById(R.id.image_avatar)).setImageResource(R.drawable.default_avatar);

        }

        // Set the TextViews accordingly
        ((TextView) cacheView.findViewById(R.id.text_label))
                .setText(tempTopStats.getLabel().toUpperCase() + "");
        if (tempTopStats.getProfile() != null) {

            ((TextView) cacheView.findViewById(R.id.text_name))
                    .setText(tempTopStats.getProfile().getUsername() + "");
            ((TextView) cacheView.findViewById(R.id.text_spm)).setText(tempTopStats.getSPM() + "");

        } else {

            ((TextView) cacheView.findViewById(R.id.text_name)).setText("N/A");
            ((TextView) cacheView.findViewById(R.id.text_spm)).setText("0");

        }
    }

    // Let's generate the table rows!
    generateTableRows(tableScores, pd.getScores(), false);
    generateTableRows(tableSPM, pd.getSpm(), false);
    generateTableRows(tableTime, pd.getTime(), true);

}