List of usage examples for android.widget TableLayout findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:org.ementasua.SwipeyTabFragment.java
private void buildDetails(final LayoutInflater inflater, TableLayout tl, final Canteen cant) { final TableLayout body = (TableLayout) inflater.inflate(R.layout.table_menu_title, null); final TableLayout body_list = (TableLayout) body.findViewById(R.id.menu_title_list); tl.addView(body);/*from w ww . j a v a 2 s.c o m*/ final Button btL = (Button) body.findViewById(R.id.bt_title_lunch); final Button btD = (Button) body.findViewById(R.id.bt_title_dinner); TextView tvDate = (TextView) body.findViewById(R.id.tv_title_date); final ImageView ib = (ImageView) body.findViewById(R.id.img_share); tvDate.setText(cant.getMicroDate()); tvDate.setGravity(Gravity.RIGHT); if (show_next_day) { Calendar c = Calendar.getInstance(); int hour = c.get(Calendar.HOUR_OF_DAY); if (hour >= 0 && hour < 16) { buildList(inflater, body_list, cant.lunch, false, btL, btD, ib); } else { buildList(inflater, body_list, cant.dinner, true, btL, btD, ib); } show_next_day = false; } else { buildList(inflater, body_list, cant.lunch, false, btL, btD, ib); } btL.setOnClickListener(new OnClickListener() { public void onClick(View v) { buildList(inflater, body_list, cant.lunch, false, btL, btD, ib); } }); btD.setOnClickListener(new OnClickListener() { public void onClick(View v) { buildList(inflater, body_list, cant.dinner, true, btL, btD, ib); } }); }
From source file:com.rstar.mobile.thermocouple.ui.FormulaFragment.java
private void displayExponential(LayoutInflater inflater) { if (inputType == inputType_T && fnResult != null && fnResult.exponential != null) { // Also display exponential String exponentialLabel = "For T>0, add correction term:"; Savelog.d(TAG, debug, "Exponential term=" + exponentialLabel); if (mExponentLabelView != null) { mExponentLabelView.setText(exponentialLabel); mExponentLabelView.setVisibility(View.VISIBLE); }/*w ww. j a v a 2s .co m*/ String data = String.format("%.3f", fnResult.E); CharSequence exponentConclude = TextUtils.concat(getText(R.string.label_E_typeK), " = ", data); if (mExponentConcludeView != null) { mExponentConcludeView.setText(exponentConclude); mExponentConcludeView.setVisibility(View.VISIBLE); } } else { if (mExponentLabelView != null) mExponentLabelView.setVisibility(View.GONE); if (mExponentConcludeView != null) mExponentConcludeView.setVisibility(View.GONE); } LinearLayout parent = mExponentialView; // Remove any existing table TableLayout tableLayoutE; if (tableExponential_Id != 0) { tableLayoutE = (TableLayout) parent.findViewById(tableExponential_Id); parent.removeView(tableLayoutE); tableExponential_Id = 0; } // Handle exponential term if exists if (inputType == inputType_T && fnResult != null && fnResult.exponential != null) { if (inflater == null) { inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); } tableExponential_Id = R.id.tableExponential_id; View view = inflater.inflate(R.layout.table_exponent, parent, true); tableLayoutE = (TableLayout) view.findViewById(tableExponential_Id); int cell_id; TextView cell; for (int row = 0; row <= 2; row++) { int term = row; cell_id = ExponentialTable.cell_ids[row][1]; cell = (TextView) tableLayoutE.findViewById(cell_id); cell.setText("" + fnResult.exponential.getTerm(term)); } // T cell_id = ExponentialTable.cell_ids[3][1]; cell = (TextView) tableLayoutE.findViewById(cell_id); cell.setText("" + fnResult.Tinput); // correction cell_id = ExponentialTable.result_ids[1]; cell = (TextView) tableLayoutE.findViewById(cell_id); String correction = String.format("%.3f", fnResult.correction); cell.setText("" + correction); } }
From source file:com.rstar.mobile.thermocouple.ui.FormulaFragment.java
private void displayPolynomial(LayoutInflater inflater) { if (inflater == null) { inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); }//w w w . j ava2 s . co m // Remove any existing table LinearLayout parent = mPolynomialView; if (tablePolynomial_Id != 0) { View view = parent.findViewById(tablePolynomial_Id); if (view != null) parent.removeView(view); } int order = -1; if (inputType == inputType_T) { if (fnResult == null) return; order = fnResult.polynomial.getOrder(); } else if (inputType == inputType_E) { if (fnInvResult == null) return; order = fnInvResult.polynomial.getOrder(); } Savelog.d(TAG, debug, "order=" + order); if (order == -1) { return; } int tableSize = 0; tablePolynomial_Id = 0; TableLayout tableLayout = null; if (order >= 0) { View view = inflater.inflate(R.layout.table_polynomial, parent, true); tableLayout = (TableLayout) view.findViewById(R.id.tablePolynomial_id); tableSize = PolynomialTable.MaxOrder; tablePolynomial_Id = R.id.tablePolynomial_id; } // Each row is a term in the polynomial for (int row = 0; row <= order; row++) { int cell_id; int column; int term = row; TextView cell; double coefficient = 0.0; if (inputType == inputType_T) { coefficient = fnResult.polynomial.getCoefficent(term); } else if (inputType == inputType_E) { coefficient = fnInvResult.polynomial.getCoefficent(term); } if (row == order) { column = 0; cell_id = PolynomialTable.cell_ids[row][column]; cell = (TextView) tableLayout.findViewById(cell_id); cell.setText("+"); } column = 1; cell_id = PolynomialTable.cell_ids[row][column]; cell = (TextView) tableLayout.findViewById(cell_id); cell.setText("" + coefficient); column = 2; cell_id = PolynomialTable.cell_ids[row][column]; cell = (TextView) tableLayout.findViewById(cell_id); cell.setText(Html.fromHtml("(" + mInput + ")<sup>" + term + "</sup>")); } for (int row = order + 1; row <= tableSize; row++) { int row_id = PolynomialTable.row_ids[row]; TableRow tableRow = (TableRow) tableLayout.findViewById(row_id); tableLayout.removeView(tableRow); } // The result row shows the value computed by the polynomial { CharSequence sumPolyLabel = ""; String sumPoly = ""; if (inputType == inputType_T) { sumPoly = String.format("%.3f", fnResult.Epoly); sumPolyLabel = EequalLabel; // If there is an exponential term, use a different label if (fnResult.exponential != null) sumPolyLabel = getText(R.string.label_EPequals); } else if (inputType == inputType_E) { sumPoly = String.format("%.3f", fnInvResult.T); sumPolyLabel = TequalLabel; } int result_id; TextView resultCell; result_id = PolynomialTable.result_ids[1]; // column 1 resultCell = (TextView) tableLayout.findViewById(result_id); resultCell.setText(sumPolyLabel); result_id = PolynomialTable.result_ids[2]; // column 2 resultCell = (TextView) tableLayout.findViewById(result_id); resultCell.setText(sumPoly); } }
From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java
private void addGridItem(String timestamp, String location, String result, int grid) { TableLayout table = (TableLayout) findViewById(grid); TableLayout row = (TableLayout) LayoutInflater.from(SamKnowsAggregateStatViewerActivity.this) .inflate(R.layout.stat_grid, null); ((TextView) row.findViewById(R.id.stat_grid_timestamp)).setText(timestamp); ((TextView) row.findViewById(R.id.stat_grid_location)).setText(location); ((TextView) row.findViewById(R.id.stat_grid_result)).setText(result); table.addView(row);/*from w w w .ja v a2s . co m*/ }
From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java
private void addGridItemFailed(String timestamp, String location, String result, int grid) { TableLayout table = (TableLayout) findViewById(grid); TableLayout row = (TableLayout) LayoutInflater.from(SamKnowsAggregateStatViewerActivity.this) .inflate(R.layout.stat_grid_fail, null); ((TextView) row.findViewById(R.id.stat_grid_timestamp)).setText(timestamp); ((TextView) row.findViewById(R.id.stat_grid_location)).setText(location); ((TextView) row.findViewById(R.id.stat_grid_result)).setText(result); table.addView(row);//from ww w . j a v a 2 s . c o m }
From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java
private void addGridItemHeader(String timestamp, String location, String result, int grid) { TableLayout table = (TableLayout) findViewById(grid); TableLayout row = (TableLayout) LayoutInflater.from(SamKnowsAggregateStatViewerActivity.this) .inflate(R.layout.stat_grid_header, null); ((TextView) row.findViewById(R.id.stat_grid_timestamp)).setText(timestamp); ((TextView) row.findViewById(R.id.stat_grid_location)).setText(location); ((TextView) row.findViewById(R.id.stat_grid_result)).setText(result); table.addView(row);/*from w w w .ja v a 2 s .c om*/ }
From source file:org.totschnig.myexpenses.activity.ExpenseEdit.java
private void switchAccountViews() { Spinner accountSpinner = mAccountSpinner.getSpinner(); Spinner transferAccountSpinner = mTransferAccountSpinner.getSpinner(); ViewGroup accountParent = (ViewGroup) findViewById(R.id.AccountRow); ViewGroup transferAccountRow = (ViewGroup) findViewById(R.id.TransferAccountRow); TableLayout table = (TableLayout) findViewById(R.id.Table); View amountRow = table.findViewById(R.id.AmountRow); View transferAmountRow = table.findViewById(R.id.TransferAmountRow); table.removeView(amountRow);/* w w w . j a v a2s. co m*/ table.removeView(transferAmountRow); if (mType == INCOME) { accountParent.removeView(accountSpinner); transferAccountRow.removeView(transferAccountSpinner); accountParent.addView(transferAccountSpinner); transferAccountRow.addView(accountSpinner); table.addView(transferAmountRow, 2); table.addView(amountRow, 4); } else { accountParent.removeView(transferAccountSpinner); transferAccountRow.removeView(accountSpinner); accountParent.addView(accountSpinner); transferAccountRow.addView(transferAccountSpinner); table.addView(amountRow, 2); table.addView(transferAmountRow, 4); } linkAccountLabels(); }