List of usage examples for android.widget TableRow addView
public void addView(View child)
Adds a child view.
From source file:com.google.cloud.solutions.cloudadventure.GameScoresFragment.java
/** * Updates the View for showing the player scores. * * @param player the player whose scores have been updated *//*from w ww . j a v a 2 s. com*/ private void updateScoresTable(Player player) { String handle = player.getHandle(); TableRow row = new TableRow(getActivity()); row.setTag(handle); TextView text = new TextView(getActivity()); text.setTag(handle + PLAYER_TAG_SUFFIX); text.setGravity(Gravity.CENTER); text.setText(handle); row.addView(text); text = new TextView(getActivity()); text.setTag(handle + GEMS_TAG_SUFFIX); text.setGravity(Gravity.CENTER); text.setText(Long.toString(player.getGemsCollected())); row.addView(text); text = new TextView(getActivity()); text.setTag(handle + MOBS_TAG_SUFFIX); text.setGravity(Gravity.CENTER); text.setText(Long.toString(player.getMobsKilled())); row.addView(text); text = new TextView(getActivity()); text.setTag(handle + DEATHS_TAG_SUFFIX); text.setGravity(Gravity.CENTER); text.setText(Long.toString(player.getNumDeaths())); row.addView(text); mScoresTable.addView(row); }
From source file:com.btmura.android.reddit.app.MarkdownTableFragment.java
private void populateTable(final View view, final LayoutInflater inflater) { final TableLayout table = (TableLayout) view.findViewById(R.id.table); MarkdownTableScanner.scan(getTableDataExtra(), new OnTableScanListener<TableRow>() { @Override/*from w ww . j a v a2 s. com*/ public TableRow onRowStart() { return new TableRow(getActivity()); } @Override public void onCell(TableRow container, Cell cell) { int layout = cell.isHeader ? R.layout.markdown_table_cell_header : R.layout.markdown_table_cell; TextView tv = (TextView) inflater.inflate(layout, container, false); tv.setGravity(cell.gravity); tv.setMovementMethod(LinkMovementMethod.getInstance()); tv.setText(formatter.formatAll(getActivity(), cell.contents)); container.addView(tv); table.setColumnShrinkable(cell.column, true); table.setColumnStretchable(cell.column, true); } @Override public void onRowEnd(TableRow row) { table.addView(row); } }); }
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);//from w w w.j a v a2 s. c om 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:net.kjmaster.cookiemom.editor.EditDataActivity.java
private void populateTable(final List<CookieTransactions> cookieTransactionsList, Context mContext) { edit_data_table.setShrinkAllColumns(true); for (final CookieTransactions cookieTransactions : cookieTransactionsList) { if ((cookieTransactions.getTransBoxes() != 0) || (cookieTransactions.getTransCash() != 0)) { TableRow tr = new TableRow(mContext); tr.setTag(cookieTransactions); TextView textView = new TextView(mContext); textView.setText(java.text.DateFormat.getInstance().format(cookieTransactions.getTransDate())); textView.setEnabled(false);/*from w w w .j av a2 s . c om*/ tr.addView(textView); TextView textView2 = new TextView(mContext); try { if (cookieTransactions.getTransScoutId() < 0) { if (cookieTransactions.getTransBoothId() > 0) { textView2.setText(cookieTransactions.getBooth().getBoothLocation()); } else { textView2.setText("Cupboard"); } } else { textView2.setText(cookieTransactions.getScout().getScoutName()); } } catch (Exception e) { textView2.setText(""); } textView2.setEnabled(false); tr.addView(textView2); TextView textView1 = new TextView(mContext); textView1.setText(cookieTransactions.getCookieType()); textView1.setEnabled(false); tr.addView(textView1); EditText textView3 = new EditText(mContext); textView3.setText(cookieTransactions.getTransBoxes().toString()); textView3.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { if (mActionMode == null) { startActionMode(actionCall); } } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { try { cookieTransactions.setTransBoxes(Integer.valueOf(editable.toString())); cookieTransactionsList.add(cookieTransactions); //Main.daoSession.getCookieTransactionsDao().update(cookieTransactions); } catch (Exception ignored) { } } }); tr.addView(textView3); EditText textView4 = new EditText(mContext); textView4.setText( NumberFormat.getCurrencyInstance().format(cookieTransactions.getTransCash().floatValue())); textView4.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { if (mActionMode == null) { startActionMode(actionCall); } } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { try { cookieTransactions.setTransCash(Double.valueOf(editable.toString())); cookieTransactionsList.add(cookieTransactions); } catch (Exception ignored) { } } }); tr.addView(textView4); edit_data_table.addView(tr); } } }
From source file:com.example.android.MainActivity.java
/**Display JSON data in table format on the user interface of android app * by clicking on the button 'Start'*/ @Override// w ww . j a v a 2s . c o m protected void onCreate(Bundle savedInstanceState) { /** * Declares TextView, Button and Tablelayout to retrieve the widgets * from User Interface. Insert the TableRow into Table and set the * gravity, font size and id of table rows and columns. * * Due to great amount of JSON data, 'for' loop method is used to insert * the new rows and columns in the table. In each loop, each of rows and * columns are set to has its own unique id. This purpose of doing this * is to allows the user to read and write the text of specific rows and * columns easily. */ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); progress = new ProgressDialog(this); StartDisplay = (Button) findViewById(R.id.btnDisplay); profile = (TableLayout) findViewById(R.id.tableLayout1); profile.setStretchAllColumns(true); profile.bringToFront(); for (int i = 1; i < 11; i++) { TableRow tr = new TableRow(this); TextView c1 = new TextView(this); TextView c2 = new TextView(this); c1.setId(i * 10 + 1); c1.setTextSize(12); c1.setGravity(Gravity.CENTER); c2.setId(i * 10 + 2); c2.setTextSize(12); c2.setGravity(Gravity.CENTER); tr.addView(c1); tr.addView(c2); tr.setGravity(Gravity.CENTER_HORIZONTAL); profile.addView(tr); } /** * onClick: Executes the DownloadWebPageTask once OnClick event occurs. * When user click on the "Start" button, * 1)the JSON data will be read from URL * 2)Progress bar will be shown till all data is read and displayed in * table form. Once it reaches 100%, it will be dismissed. * * Progress Bar: The message of the progress bar is obtained from strings.xml. * New thread is created to handle the action of the progress bar. */ StartDisplay.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final String TAG = "MyActivity"; progress.setMessage(getResources().getString(R.string.ProgressBar_message)); progress.setCancelable(true); progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progress.setProgress(0); progress.setMax(100); progress.show(); new Thread(new Runnable() { public void run() { while (ProgressBarStatus < 100) { try { Thread.sleep(500); } catch (InterruptedException e) { Log.e(TAG, Log.getStackTraceString(e)); } progressBarbHandler.post(new Runnable() { public void run() { progress.setProgress(ProgressBarStatus); } }); } if (ProgressBarStatus >= 100) { try { Thread.sleep(1000); } catch (InterruptedException e) { Log.e(TAG, Log.getStackTraceString(e)); } progress.dismiss(); } } }).start(); DownloadWebPageTask task = new DownloadWebPageTask(); task.execute("http://private-ae335-pgserverapi.apiary.io/user/profile/234"); StartDisplay.setClickable(false); } }); }
From source file:com.adamkruger.myipaddressinfo.NetworkInfoFragment.java
private TableRow makeTableRow(TextView label, TextView value) { TableRow tableRow = new TableRow(getActivity()); tableRow.setLayoutParams(/*from w ww . j a v a 2 s . c om*/ new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); tableRow.addView(label); if (value != null) { tableRow.addView(value); } return tableRow; }
From source file:org.mifos.androidclient.templates.OperationFormActivity.java
public void setOperationSummaryContent(Map<String, String> operationResults) { TableLayout operationSummary = (TableLayout) findViewById(R.id.operationForm_operationSummary); TableLayoutHelper helper = new TableLayoutHelper(this); operationSummary.removeAllViews();//from w w w . ja va2s .c o m for (Map.Entry<String, String> entry : operationResults.entrySet()) { if (!entry.getKey().equals(STATUS_KEY)) { TableRow row = helper.createTableRow(); TextView cell = helper.createTableCell( ServerMessageTranslator.translate(this, entry.getKey(), entry.getKey()), 1); row.addView(cell); cell = helper.createTableCell( ServerMessageTranslator.translate(this, entry.getValue(), entry.getValue()), 2); row.addView(cell); operationSummary.addView(row); } } }
From source file:com.jeffreyawest.weblogic.monitor.charting.DefaultPieChart.java
protected final TableRow getRow(final Activity pActivity, int pColor, String pValue) { TableRow row = new TableRow(pActivity); row.setPadding(2, 2, 2, 2);/* ww w . j av a2 s . c om*/ pActivity.getResources().getDimension(R.dimen.graph_fragment_legend_graphic_size); TextView colorView = new TextView(pActivity); colorView.setBackgroundColor(pColor); colorView .setHeight((int) pActivity.getResources().getDimension(R.dimen.graph_fragment_legend_graphic_size)); colorView.setText(" "); colorView.setWidth((int) pActivity.getResources().getDimension(R.dimen.graph_fragment_legend_graphic_size)); row.addView(colorView); TextView text = new TextView(pActivity); text.setText(pValue); text.setPadding(2, 2, 2, 2); text.setTextSize(15); row.addView(text); return row; }
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); tl.addView(tr, matchAndWrapTableLayout()); for (AccountInfo cc : ccs) { addReviewerRow(tl, cc);//from w w w.j a v a 2 s. c om } } }
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);//from w w w .j av a 2 s. co m final TextView colorLabel = new TextView(getContext()); colorLabel.setText(getString(R.string.color)); colorLabel.setTextColor(Color.BLACK); colorParameter.addView(colorLabel); 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$ }