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.aquabase.DetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
    View rootView = inflater.inflate(R.layout.fragment_details, container, false);

    // Fill the table layout with rows for the fields depending on the item
    TableLayout table = (TableLayout) rootView.findViewById(R.id.TableLayout);

    for (int i = 0; i < mLabelIds.size(); i++) {
        // Don't switch to an inflated XML file for each row: way too slow
        TableRow row = new TableRow(getActivity());
        row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        row.setPadding(0, 3, 0, 3);//  w  ww . j  ava 2 s . c  o  m

        TextView titleView = new TextView(getActivity());
        titleView.setText(mLabelIds.get(i));
        titleView.setPadding(0, 0, 12, 0);
        titleView.setGravity(Gravity.TOP);
        titleView.setTypeface(Typeface.DEFAULT_BOLD);
        row.addView(titleView);

        TextView valueView = new TextView(getActivity());
        valueView.setText(mValues.get(i));
        titleView.setGravity(Gravity.TOP);
        row.addView(valueView);

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

    return rootView;
}

From source file:loonyb.in.posmachine.InvoiceFragment.java

private TableRow itemsHeader() {
    Context c = getActivity();//  ww w . j  a  va  2s.  com
    Resources res = getResources();
    String[] headers = res.getStringArray(R.array.item_header);

    TableRow row = new TableRow(c);

    for (int i = 0; i < headers.length; i++) {
        TextView column = new TextView(c);
        column.setText(headers[i]);
        row.addView(column);
    }

    return row;
}

From source file:hongik.android.project.best.HistoryActivity.java

public void drawHistory() {
    int rowCnt = historyTable.getChildCount();
    Log.i("ROWCOUNT", rowCnt + "");
    String query = "func=history&cid=" + cid;
    DBConnector conn = new DBConnector(query);
    conn.start();/*from w w w  . ja  v  a  2 s  . c  o m*/

    try {
        conn.join();
        JSONObject jsonResult = conn.getResult();
        boolean result = (boolean) jsonResult.get("result");

        if (!result)
            return;

        TableRow motive = (TableRow) historyTable.getChildAt(1);
        JSONArray jsonArray = jsonResult.getJSONArray("values");

        for (int i = 0; i < jsonArray.length(); i++) {
            TableRow tbRow = new TableRow(this);
            final TextViewPlus[] tbCols = new TextViewPlus[4];
            JSONObject json = jsonArray.getJSONObject(i);
            String[] elements = new String[4];

            elements[0] = json.getString("SNAME");
            elements[1] = Double.parseDouble(json.getString("GRADE")) + "";
            elements[2] = json.getString("NOTE");
            elements[3] = json.getString("DAY");
            final String license = json.getString("LICENSE#");

            if (elements[2].length() > 14)
                elements[2] = elements[2].substring(0, 14) + "...";

            for (int j = 0; j < 4; j++) {
                tbCols[j] = new TextViewPlus(this);
                tbCols[j].setText(elements[j]);
                tbCols[j].setLayoutParams(motive.getChildAt(j).getLayoutParams());
                tbCols[j].setGravity(Gravity.CENTER);
                tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(),
                        "InterparkGothicBold.ttf"));
                final HistoryActivity originActivity = this;
                tbCols[j].setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class);
                        reviewIntent.putExtra("ACCESS", "HISTORY");
                        reviewIntent.putExtra("CID", cid);
                        reviewIntent.putExtra("LICENSE", license);
                        startActivity(reviewIntent);
                    }
                });

                Log.i("History", "COL" + j + ":" + elements[j]);

                tbRow.addView(tbCols[j]);
            }
            historyTable.addView(tbRow);
        }
        for (int i = 1; i < rowCnt; i++) {
            historyTable.removeViewAt(1);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.github.tetravex_android.fragment.HiScoreTableFragment.java

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

    // Set the label for the size of the board
    TextView tableSize = (TextView) rootView.findViewById(R.id.hi_score_board_size);
    tableSize.setText(mLabel);// www.jav  a 2 s .c  o m

    TableLayout table = (TableLayout) rootView.findViewById(R.id.hi_score_table_layout);

    // fill the table from the database cursor
    if (mScoreCursor != null) {
        // move cursor to first row, will return false if cursor is empty
        if (mScoreCursor.moveToFirst()) {
            do {
                // set time from the database entry, format text
                TextView timeTv = new TextView(rootView.getContext());
                timeTv.setText(mScoreCursor.getString(Constants.DB_TIME_COL_IDX));
                timeTv.setTextAppearance(rootView.getContext(), R.style.score_table_entry);

                // set date from the database entry, format text
                TextView dateTv = new TextView(rootView.getContext());
                String unixTimeStr = mScoreCursor.getString(Constants.DB_DATE_COL_IDX);
                long unixSeconds = Long.valueOf(unixTimeStr);
                Date date = new Date(unixSeconds);
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                String formattedDate = sdf.format(date);
                dateTv.setText(formattedDate);
                dateTv.setTextAppearance(rootView.getContext(), R.style.score_table_entry);

                // add the Views from the database entry to the TableLayout
                TableRow row = new TableRow(rootView.getContext());
                row.addView(timeTv);
                row.addView(dateTv);
                table.addView(row);

                // add row separator
                View spacerView = new View(rootView.getContext());
                TableLayout.LayoutParams params = new TableLayout.LayoutParams();
                params.width = TableLayout.LayoutParams.MATCH_PARENT;
                params.height = 1;
                spacerView.setLayoutParams(params);
                spacerView.setBackgroundColor(getResources().getColor(R.color.tile_bkgnd_gray));
                table.addView(spacerView);
                // move to next row
            } while (mScoreCursor.moveToNext());
        }
    }

    return rootView;
}

From source file:de.uulm.graphicalpasswords.opentapi.TAPILoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tapi_login);
    // Show the Up button in the action bar.
    setupActionBar();//from  ww w  .j av  a2 s  . c om

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    length = Integer.parseInt(sharedPref.getString("tapi_length", "6"));
    password = sharedPref.getString("tapi_pw", "");
    input = new String[length];

    for (int i = 0; i < images.length; i++) {
        images[i] = sharedPref.getInt("image" + i, 0);
    }

    EditText editText = (EditText) findViewById(R.id.tapi_edittext);
    text = editText.getText();
    back = (Button) findViewById(R.id.tapi_back);
    clear = (Button) findViewById(R.id.tapi_clear);
    save = (Button) findViewById(R.id.tapi_save);

    TableLayout table = (TableLayout) findViewById(R.id.tapi_imagetable);

    LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    TableRow row = null;
    for (int i = 0; i < imageViews.length; i++) {
        if (i % 4 == 0) {
            row = new TableRow(this);
        }
        imageViews[i] = new PassImageView(this);
        imageViews[i].setLayoutParams(layoutParams);
        imageViews[i].setAdjustViewBounds(true);
        imageViews[i].setScaleType(ScaleType.CENTER_INSIDE);
        imageViews[i].setPadding(5, 5, 5, 5);
        imageViews[i].setImageResource(images[i]);
        row.addView(imageViews[i]);
        if (i % 4 == 3) {
            table.addView(row);
        }
        imageViews[i].setOnTouchListener(new TAPIOnTouchListener(this, imageViews[i]));
    }
}

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));
    }//from w ww  .  j a v a  2 s.com

    //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.jeffreyawest.weblogic.monitor.activity.display.DisplayClusterActivity.java

private View getSeparatorRow() {
    TableRow row = new TableRow(this);
    TextView sep;/* ww  w  .  j av a 2s  .  c  o m*/

    sep = new TextView(this);
    sep.setText("---");
    row.addView(sep);
    return row;
}

From source file:org.smap.smapTask.android.activities.TaskAddressActivity.java

/** Called when the activity is first created. */
@Override//ww  w. j a  va  2  s. c  om
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.task_address);

    // Get the id of the selected list item
    Bundle bundle = getIntent().getExtras();

    taskEntry = Utilities.getTaskWithId(bundle.getLong("id"));

    try {

        //String assignment_status = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_STATUS));
        //String taskTitle = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_TITLE));
        //String taskAddress = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_ADDRESS));

        // Formatting
        LinearLayout.LayoutParams textLayout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        textLayout.setMargins(1, 1, 1, 1);

        TableRow.LayoutParams trLayout = new TableRow.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT);
        trLayout.setMargins(1, 1, 1, 1);

        TableLayout tableLayout = (TableLayout) findViewById(R.id.task_address_values);

        // Add Title
        TextView title = (TextView) findViewById(R.id.task_title);
        title.setText(taskEntry.name);

        // Add Status
        TableRow r = new TableRow(this);
        r.setLayoutParams(trLayout);
        r.setBackgroundColor(0xff0000);
        TextView text1 = new TextView(this);
        text1.setText("Status");
        text1.setBackgroundColor(0xff0000);
        TextView text2 = new TextView(this);
        text2.setText(taskEntry.taskStatus);
        text2.setBackgroundColor(0xff0000);
        r.addView(text1);
        r.addView(text2);
        tableLayout.addView(r);

        // Put the Address items in the table
        Type type = new TypeToken<ArrayList<Address>>() {
        }.getType();
        ArrayList<Address> aArray = new Gson().fromJson(taskEntry.taskAddress, type);
        if (aArray != null) {
            for (int i = 0; i < aArray.size(); i++) {

                r = new TableRow(this);
                r.setLayoutParams(trLayout);
                r.setBackgroundColor(0xff0000);

                text1 = new TextView(this);
                text1.setText(aArray.get(i).name);
                text1.setBackgroundColor(0xff0000);

                text2 = new TextView(this);
                text2.setText(aArray.get(i).value);
                text2.setBackgroundColor(0xff0000);

                r.addView(text1);
                r.addView(text2);
                tableLayout.addView(r);
            }
        }

        // Create the buttons
        LinearLayout buttons = (LinearLayout) findViewById(R.id.task_address_buttons);
        //menu.setHeaderTitle(taskTitle);
        if (Utilities.canReject(taskEntry.taskStatus)) {

            Button b = new Button(this);
            b.setText("Reject Task");
            b.setId(R.id.reject_button);
            b.setOnClickListener(this);
            buttons.addView(b);
        }
        if (Utilities.canComplete(taskEntry.taskStatus)) {
            Button b = new Button(this);
            b.setText("Complete Task");
            b.setId(R.id.complete_button);
            b.setOnClickListener(this);
            buttons.addView(b);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

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);
        }// www .j  a v a2 s . co m

        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);

}