Example usage for android.widget TableLayout addView

List of usage examples for android.widget TableLayout addView

Introduction

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

Prototype

@Override
public void addView(View child) 

Source Link

Usage

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

private void createColorBoxes(TableLayout parameters) {
    final ColorModel color = this.object.getColor();
    this.colorValue = Color.argb(color.getAlpha(), color.getR(), color.getG(), color.getB());

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

    final TextView colorLabel = new TextView(getContext());
    colorLabel.setText(getString(R.string.color));
    colorLabel.setTextColor(Color.BLACK);
    colorParameter.addView(colorLabel);/*  w  w  w .  j a  va  2 s .co m*/

    this.colorButton = new Button(getContext());
    updateColorButton();
    colorParameter.addView(this.colorButton);

    this.colorButton.setOnClickListener(new OnClickListener() {

        /**
         * {@inheritDoc}
         */
        public void onClick(View v) {
            openColorPicker(AbstractObjectEditor.this.colorValue);
        }
    });

    this.colorAlpha = new ParameterInputBox(getContext(), this, this);
    parameters.addView(this.colorAlpha);
    this.colorAlpha.setName(R.string.color_alpha);
    this.colorAlpha.setValue("" + color.getAlpha()); //$NON-NLS-1$
    this.colorAlpha.setUnit(""); //$NON-NLS-1$
}

From source file:com.bonsai.btcreceive.ViewTransactionActivity.java

private void addTransputsSum(TableLayout table, long btc) {
    TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.transputs_table_sum, table, false);

    TextView tv1 = (TextView) row.findViewById(R.id.row_btc);
    tv1.setText(String.format("%s", mBTCFmt.format(btc)));

    table.addView(row);
}

From source file:com.jdom.word.playdough.android.GamePackPlayerActivity.java

public void updateSourceLetters(List<ButtonConfiguration> buttons) {
    TableLayout availableLettersTable = (TableLayout) findViewById(R.id.source_letters_table);
    availableLettersTable.removeAllViews();
    TableRow row = new TableRow(this);

    for (int i = 0; i < buttons.size(); i++) {
        final ButtonConfiguration buttonConfiguration = buttons.get(i);
        final String displayText = buttonConfiguration.getDisplayText();
        final boolean shouldBeEnabled = buttonConfiguration.isEnabled();
        final Runnable clickAction = buttonConfiguration.getClickAction();

        if (i == 9 || i == 18) {
            availableLettersTable.addView(row);
            row = new TableRow(this);
        }/*from  w ww. j  ava2  s  .com*/

        final Button button = new Button(this);
        button.setText(displayText);
        button.setClickable(shouldBeEnabled);
        button.setEnabled(shouldBeEnabled);
        button.setBackgroundColor(Color.BLACK);
        button.setTextSize(20);
        int color = (shouldBeEnabled) ? Color.WHITE : Color.BLACK;
        button.setTextColor(color);

        if (clickAction != null) {
            button.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    clickAction.run();
                }
            });
        }

        row.addView(button);
    }
    availableLettersTable.addView(row);

}

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 v a2  s.c om*/
    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.svpino.longhorn.artifacts.StockTileProcessor.java

private static int createFixedHeaderRow(Fragment fragment, TableLayout tableLayout, List<Stock> stocks,
        SparseArray<View> tiles, int height, int margin) {

    View view = tableLayout.getChildAt(0);

    if (view == null || view.getTag() != "fixed-header") {
        TableRow indexesTableRow = new TableRow(fragment.getActivity());

        TableRow.LayoutParams indixesLayoutParams = new TableRow.LayoutParams();
        indixesLayoutParams.topMargin = margin;
        indixesLayoutParams.rightMargin = margin;
        indixesLayoutParams.bottomMargin = margin;
        indixesLayoutParams.height = height;

        TableRow.LayoutParams lastIndexLayoutParams = new TableRow.LayoutParams();
        lastIndexLayoutParams.topMargin = margin;
        lastIndexLayoutParams.bottomMargin = margin;
        lastIndexLayoutParams.height = height;

        View tile1 = createTile(fragment, stocks.get(0), 0, false);
        View tile2 = createTile(fragment, stocks.get(1), 1, false);
        View tile3 = createTile(fragment, stocks.get(2), 2, false);

        tiles.put(0, tile1);/*from  w ww. j  av  a  2  s .  c  o  m*/
        tiles.put(1, tile2);
        tiles.put(2, tile3);

        indexesTableRow.addView(tile1, indixesLayoutParams);
        indexesTableRow.addView(tile2, indixesLayoutParams);
        indexesTableRow.addView(tile3, lastIndexLayoutParams);
        indexesTableRow.setTag("fixed-header");

        tableLayout.addView(indexesTableRow);
    }

    return 3;
}

From source file:nl.openkvk.MainActivity.java

private void globalSearchResults(Object obj) {
    {//from  w w w .  jav  a2s  .  c  om
        Log.d("Result", obj.toString());
        TableLayout tl = (TableLayout) findViewById(R.id.tableOuter);
        tl.removeAllViews();
        JSONResult res = new JSONResult((JSONObject) ((JSONObject) ((JSONArray) obj).get(0)).get("RESULT"));
        if (res.size() < 1) {
            TextView v1 = new TextView(this);
            v1.setText("Niets gevonden voor deze zoekvraag.");
            TableRow tr = new TableRow(this);
            tr.addView(v1);
            tl.addView(tr);
        }
        for (int r = 0; r < res.size(); r++) {
            {
                TableRow tr = new TableRow(this);
                TextView v1 = new TextView(this);
                tr.addView(v1);
                tl.addView(tr);
            }
            print(tl, "Naam: ", res.getValue(r, "bedrijfsnaam"));
            print(tl, "KvK: ", res.getValue(r, "kvks"));
            print(tl, "VestNr: ", res.getValue(r, "vestiging"));
            print(tl, "Type: ", res.getValue(r, "type"));
            print(tl, "Rechtsvorm: ", res.getValue(r, "rechtsvorm"));
            print(tl, "Status: ", res.getValue(r, "status"));
            print(tl, "Website: ", res.getValue(r, "website"));
            print(tl, "ANBI: ", res.getValue(r, "anbi"));
            print(tl, "Adres: ", res.getValue(r, "adres"));
            String po = res.getValue(r, "postcode");
            String pl = res.getValue(r, "plaats");
            if (po != null || pl != null) {
                if (po == null) {
                    print(tl, "", pl);
                } else if (pl == null) {
                    print(tl, "", po);
                } else {
                    print(tl, "", po + " " + pl);
                }
            }
            {
                TableRow tr = new TableRow(this);
                if (res.getValue(r, "kvk") != null && res.getValue(r, "kvks") != null) {
                    Button but = new Button(this);
                    but.setText("Details");
                    but.setTextSize(10);
                    but.setOnClickListener(new KvkButListener(res.getValue(r, "kvk"), res.getValue(r, "kvks")));
                    tr.addView(but);
                } else {
                    tr.addView(new TextView(this));
                }
                tr.addView(new TextView(this));
                if (po != null) {
                    Button but = new Button(this);
                    but.setText("Postcode");
                    but.setTextSize(10);
                    but.setOnClickListener(new PostcodeButListener(po));
                    tr.addView(but);
                }
                tl.addView(tr);
            }
        }
    }
}

From source file:de.tobiasbielefeld.solitaire.ui.manual.ManualGames.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_manual_games, container, false);

    ((Manual) getActivity()).setGamePageShown(false);

    layout1 = (ScrollView) view.findViewById(R.id.manual_games_layout_selection);
    scrollView = (ScrollView) view.findViewById(R.id.manual_games_scrollView);
    textName = (TextView) view.findViewById(R.id.manual_games_name);
    textStructure = (TextView) view.findViewById(R.id.manual_games_structure);
    textObjective = (TextView) view.findViewById(R.id.manual_games_objective);
    textRules = (TextView) view.findViewById(R.id.manual_games_rules);
    textScoring = (TextView) view.findViewById(R.id.manual_games_scoring);
    textBonus = (TextView) view.findViewById(R.id.manual_games_bonus);

    layout1.setVisibility(View.VISIBLE);
    scrollView.setVisibility(View.GONE);

    //if the manual is called from the in game menu, show the corresponding game rule page
    if (getArguments() != null && getArguments().containsKey(GAME)) {
        loadGameText(getArguments().getString(GAME));
    }/*w ww  .  ja v  a 2 s  .c o m*/

    //load the table
    String[] gameList = lg.getDefaultGameNameList(getResources());
    TableRow row = new TableRow(getContext());
    TableLayout tableLayout = (TableLayout) view.findViewById(R.id.manual_games_container);
    TypedValue typedValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true);

    TableRow.LayoutParams params = new TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT);
    params.weight = 1;

    //add each button
    for (int i = 0; i < lg.getGameCount(); i++) {
        Button entry = new Button(getContext());

        if (i % COLUMNS == 0) {
            row = new TableRow(getContext());
            tableLayout.addView(row);
        }

        entry.setBackgroundResource(typedValue.resourceId);
        entry.setEllipsize(TextUtils.TruncateAt.END);
        entry.setMaxLines(1);
        entry.setLayoutParams(params);
        entry.setText(gameList[i]);
        entry.setOnClickListener(this);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            entry.setAllCaps(false);
        }

        row.addView(entry);
    }

    //add some dummies to the last row, if necessary
    while (row.getChildCount() < COLUMNS) {
        FrameLayout dummy = new FrameLayout(getContext());
        dummy.setLayoutParams(params);
        row.addView(dummy);
    }

    return view;
}

From source file:com.google.adsensequickstart.DisplayReportFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ScrollView sv = new ScrollView(getActivity());
    TableLayout tl = new TableLayout(getActivity());
    sv.addView(tl);/*  w  w  w.  jav  a2s . c  om*/

    if (displayReportController == null) {
        return sv;
    }
    AdsenseReportsGenerateResponse response = displayReportController.getReportResponse();

    TableLayout.LayoutParams tableRowParams = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    tableRowParams.setMargins(10, 10, 10, 10);

    TableRow.LayoutParams tvParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    tvParams.setMargins(10, 10, 10, 10);

    List<Headers> headers = response.getHeaders();
    TableRow tr = new TableRow(getActivity());
    tl.addView(tr);

    for (Headers header : headers) {
        TextView tv = new TextView(getActivity());
        tv.setText(header.getName());
        tr.setLayoutParams(tableRowParams);
        tr.addView(tv);
    }
    if (response.getRows() != null && !response.getRows().isEmpty()) {
        for (List<String> row : response.getRows()) {
            TableRow trow = new TableRow(getActivity());
            tl.addView(trow);
            for (String cell : row) {
                TextView tv = new TextView(getActivity());
                tv.setText(cell);
                trow.addView(tv);
                tv.setLayoutParams(tvParams);
                tv.setPadding(15, 5, 15, 5);
                tv.setBackgroundColor(Color.WHITE);
            }
        }
    }
    return sv;
}

From source file:com.bonsai.wallet32.SweepKeyActivity.java

private void addAccountHeader(TableLayout table) {
    TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.receive_to_header, table, false);

    TextView tv = (TextView) row.findViewById(R.id.header_btc);
    tv.setText(mBTCFmt.unitStr());//  w  w  w  .j  av  a 2s. c  o  m

    table.addView(row);
}

From source file:com.bonsai.wallet32.MainActivity.java

private void addBalanceSum(TableLayout table, String acct, long btc, double fiat) {
    TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.balance_table_sum, table, false);

    TextView tv0 = (TextView) row.findViewById(R.id.row_label);
    tv0.setText(acct);// w w w  .  ja  v a  2  s  .c om

    TextView tv1 = (TextView) row.findViewById(R.id.row_btc);
    tv1.setText(mBTCFmt.formatCol(btc, 0, true, true));

    TextView tv2 = (TextView) row.findViewById(R.id.row_fiat);
    tv2.setText(String.format("%.02f", fiat));

    table.addView(row);
}