List of usage examples for android.widget TableRow TableRow
public TableRow(Context context)
Creates a new TableRow for the given context.
From source file:Main.java
private static TableRow generateAfiTblRow(Context context, String first, String second) { TableRow tr = new TableRow(context); tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); LayoutParams childLp = new LayoutParams(0, LayoutParams.FILL_PARENT, 1); TextView amount = new TextView(context); amount.setText(first);/*from w ww .j a v a2s . c o m*/ amount.setGravity(Gravity.CENTER); tr.addView(amount, childLp); TextView score = new TextView(context); score.setText(second); score.setGravity(Gravity.CENTER); tr.addView(score, childLp); return tr; }
From source file:Main.java
/** * Add button to the layout as the left one on a row. * * @param act The running activity.// w w w. j a v a 2 s .c om * @param table The table of buttons. * @param lastRow The previous row of buttons. * @param actName Name of the activity. * @return The Button object that is constructed. */ private static Button addButtonAsFirst(Activity act, TableLayout table, TableRow lastRow, String actName) { /** * Create new row for the table. */ TableRow newRow = new TableRow(act); newRow.setLayoutParams(lastRow.getLayoutParams()); /** * Create both buttons. Set the second invisible. */ Button old = (Button) lastRow.getChildAt(0); Button left = new Button(act); left.setText(actName); left.setLayoutParams(old.getLayoutParams()); Button right = new Button(act); right.setText("TempButton"); right.setLayoutParams(old.getLayoutParams()); right.setVisibility(View.INVISIBLE); /** * Add them on. */ newRow.addView(left); newRow.addView(right); table.addView(newRow); return left; }
From source file:com.svpino.longhorn.artifacts.StockTileProcessor.java
public static void create(Fragment fragment, TableLayout tableLayout, List<Stock> stocks, SparseArray<View> tiles, boolean restart) { if (restart) { tableLayout.removeAllViews();//from ww w. ja v a 2 s . com if (tiles != null) { tiles.clear(); } } tableLayout.setStretchAllColumns(true); tableLayout.setShrinkAllColumns(true); int margin = Extensions.dpToPixels(fragment.getResources(), 3); int height = Extensions.dpToPixels(fragment.getResources(), 90); int index = createFixedHeaderRow(fragment, tableLayout, stocks, tiles, height, margin); int row = index == 3 ? 1 : 0; while (index < stocks.size()) { index = createStandardRow(fragment, tableLayout, stocks, tiles, height, margin, index, row); row++; } while (tableLayout.getChildCount() > row) { tableLayout.removeViewAt(tableLayout.getChildCount() - 1); } if (stocks.size() % 2 != 0) { TableRow tableRow = new TableRow(fragment.getActivity()); View addNewStockTile = createTileForAddingNewStock(fragment); tableRow.addView(addNewStockTile, getSpannedLayoutParams(row, margin, height)); tableLayout.addView(tableRow); } else { TableRow tableRow = (TableRow) tableLayout.getChildAt(tableLayout.getChildCount() - 1); LayoutParams layoutParams = (TableRow.LayoutParams) tableRow.getChildAt(0).getLayoutParams(); layoutParams.bottomMargin = margin; layoutParams.height = height; } }
From source file:com.jeffreyawest.weblogic.monitor.activity.display.DisplayEntityActivity.java
public TableRow getRow(String pLabel, String pValue) { TableRow row = new TableRow(this); TextView textView = new TextView(this); textView.setText(pLabel);//from w w w . jav a 2 s . c om float dimension = this.getResources().getDimension(R.dimen.entity_details_table_text_size); textView.setTextSize(dimension); row.addView(textView); textView = new TextView(this); textView.setText(pValue); textView.setTextSize(dimension); row.addView(textView); return row; }
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 . ja v a 2 s .co m 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:hongik.android.project.best.StoreReviewActivity.java
public void drawTable() throws Exception { String query = "func=morereview" + "&license=" + license; DBConnector conn = new DBConnector(query); conn.start();/*from ww w .j av a 2 s .c o m*/ conn.join(); JSONObject jsonResult = conn.getResult(); boolean result = jsonResult.getBoolean("result"); if (!result) { return; } String storeName = jsonResult.getString("sname"); ((TextViewPlus) findViewById(R.id.storereview_storename)).setText(storeName); JSONArray review = null; if (!jsonResult.isNull("review")) { review = jsonResult.getJSONArray("review"); } //Draw Review Table if (review != null) { TableRow motive = (TableRow) reviewTable.getChildAt(1); for (int i = 0; i < review.length(); i++) { JSONObject json = review.getJSONObject(i); final String[] elements = new String[4]; elements[0] = Double.parseDouble(json.getString("GRADE")) + ""; elements[1] = json.getString("NOTE"); elements[2] = json.getString("CID#"); elements[3] = json.getString("DAY"); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[4]; if (elements[1].length() > 14) elements[1] = elements[1].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")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class); reviewIntent.putExtra("ACCESS", "STORE"); reviewIntent.putExtra("CID", elements[2]); reviewIntent.putExtra("LICENSE", license); Log.i("StoreReview", "StartActivity"); startActivity(reviewIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } reviewTable.addView(tbRow); } } reviewTable.removeViewAt(1); }
From source file:gidaibero.android.matsol.MatrixDisplayActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); target = R.id.matrix_button;/*from w w w .ja v a 2 s. com*/ int currentIndex; TableRow tableRow; // Define the layout. setContentView(R.layout.matrix_display_view); // Parse the values from the parent Intent intent = getIntent(); this.height = intent.getIntExtra(MatrixInputActivity.MATRIX_SIZE, 5); this.matrix = new float[this.height][]; for (int i = 0; i < this.height; i++) { this.matrix[i] = intent.getFloatArrayExtra(MatrixInputActivity.MATRIX_VALUES + i); } this.results = intent.getFloatArrayExtra(MatrixInputActivity.MATRIX_RESULTS); // the we are always a linear equation this.width = this.height + 1; // initialize the array this.textViewArray = new TextView[this.width * this.height]; // get the table view to draw in it matrixTable = (TableLayout) findViewById(R.id.matrix_display_table); // traverse rows for (int i = 0; i < this.height; i++) { //traverse each element of the row tableRow = new TableRow(this); for (int j = 0; j < this.width; j++) { currentIndex = i * this.width + j; // this points to the location of t // editText in the matrix this.textViewArray[currentIndex] = new TextView(this); this.textViewArray[currentIndex] .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); this.textViewArray[currentIndex].setPadding(5, 5, 5, 5); if (j == this.width - 1) { this.textViewArray[currentIndex].setText(" " + this.results[i]); } else { this.textViewArray[currentIndex].setText(" " + this.matrix[i][j]); } tableRow.addView(this.textViewArray[currentIndex]); } textViewArray[0].measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); // this will add target and position-specific views to hint the // user of what we are doing tableRow = decorateTableRow(tableRow, textViewArray[0].getMeasuredHeight(), textViewArray[0].getMeasuredWidth(), i); matrixTable.addView(tableRow, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); } }
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 w w. j av a 2 s . c om*/ 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:com.google.adsensequickstart.DisplayInventoryFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ScrollView sv = new ScrollView(getActivity()); TableLayout tl = new TableLayout(getActivity()); tl.setBackgroundColor(Color.rgb(242, 239, 233)); sv.addView(tl);/* w w w. j a va 2 s . c om*/ if (displayInventoryController == null) { return sv; } Inventory inventory = displayInventoryController.getInventory(); TableLayout.LayoutParams tableRowParams = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); tableRowParams.setMargins(1, 1, 1, 1); TableRow.LayoutParams accountLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); accountLayoutParams.setMargins(2, 1, 2, 1); TableRow.LayoutParams adCLientLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); adCLientLayoutParams.setMargins(12, 1, 2, 1); TableRow.LayoutParams adUnitChannelLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); adUnitChannelLayoutParams.setMargins(24, 1, 2, 1); for (String accountId : inventory.getAccounts()) { TableRow trow = new TableRow(getActivity()); tl.addView(trow); TextView tv = new TextView(getActivity()); tv.setText(accountId); trow.addView(tv); tv.setLayoutParams(accountLayoutParams); for (String adClient : inventory.getAdClients(accountId)) { TableRow trow2 = new TableRow(getActivity()); trow2.setBackgroundColor(Color.rgb(214, 204, 181)); tl.addView(trow2); TextView tv2 = new TextView(getActivity()); tv2.setText(adClient); trow2.addView(tv2); tv2.setLayoutParams(adCLientLayoutParams); for (String adUnit : inventory.getAdUnits(adClient)) { TableRow trow3 = new TableRow(getActivity()); trow3.setBackgroundColor(Color.rgb(251, 145, 57)); tl.addView(trow3); TextView tv3 = new TextView(getActivity()); tv3.setText(adUnit); trow3.addView(tv3); tv3.setLayoutParams(adUnitChannelLayoutParams); } for (String customChannel : inventory.getCustomChannels(adClient)) { TableRow trow3 = new TableRow(getActivity()); trow3.setBackgroundColor(Color.rgb(255, 195, 69)); tl.addView(trow3); TextView tv3 = new TextView(getActivity()); tv3.setText(customChannel); trow3.addView(tv3); tv3.setLayoutParams(adUnitChannelLayoutParams); } } } return sv; }
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);// w ww . j a va2 s. co 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; }