List of usage examples for android.widget TableRow setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
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 www .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.//from w w w .j a v a 2 s.co m * @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: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 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:com.karthikb351.vitinfo2.fragment.grades.GradesFragment.java
void fillGradeCountData() { for (int i = 0; i < gradeCounts.size(); i++) { TableRow row = new TableRow(getActivity()); row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); row.addView(createTextView(gradeCounts.get(i).getGrade())); row.addView(createTextView(Integer.toString(gradeCounts.get(i).getCount()))); gradeCountTable.addView(row);/*w w w . j av a 2 s. c o m*/ } }
From source file:com.google.reviewit.AddReviewerFragment.java
private void addReviewerRow(TableLayout tl, AccountInfo reviewer) { TableRow tr = new TableRow(getContext()); tr.setLayoutParams(matchAndWrapTableRowLayout()); ImageView avatar = new ImageView(getContext()); TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(widgetUtil.dpToPx(20), widgetUtil.dpToPx(20));/* w ww . j av a2 s .co m*/ layoutParams.setMargins(0, 0, widgetUtil.dpToPx(5), widgetUtil.dpToPx(2)); avatar.setLayoutParams(layoutParams); WidgetUtil.displayAvatar(getApp(), reviewer, avatar); tr.addView(avatar); TextView reviewerName = new TextView(getContext()); reviewerName.setLayoutParams(wrapTableRowLayout()); reviewerName.setText(FormatUtil.format(reviewer)); tr.addView(reviewerName); tl.addView(tr, matchAndWrapTableLayout()); }
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);//from w w w. ja va 2 s. com tl.addView(tr, matchAndWrapTableLayout()); for (AccountInfo cc : ccs) { addReviewerRow(tl, cc); } } }
From source file:com.mifos.utils.DataTableUIBuilder.java
public LinearLayout getDataTableLayout(final DataTable dataTable, JsonArray jsonElements, LinearLayout parentLayout, final Context context, final int entityId, DataTableActionListener mListener) { dataTableActionListener = mListener; /**/*from www . j a va 2s . c o m*/ * Create a Iterator with Json Elements to Iterate over the DataTable * Response. */ Iterator<JsonElement> jsonElementIterator = jsonElements.iterator(); /* * Each Row of the Data Table is Treated as a Table Here. * Creating the First Table for First Row */ tableIndex = 0; while (jsonElementIterator.hasNext()) { TableLayout tableLayout = new TableLayout(context); tableLayout.setPadding(10, 10, 10, 10); final JsonElement jsonElement = jsonElementIterator.next(); /* * Each Entry in a Data Table is Displayed in the * form of a table where each row contains one Key-Value Pair * i.e a Column Name - Column Value from the DataTable */ int rowIndex = 0; while (rowIndex < dataTable.getColumnHeaderData().size()) { TableRow tableRow = new TableRow(context); tableRow.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); tableRow.setPadding(10, 10, 10, 10); if (rowIndex % 2 == 0) { tableRow.setBackgroundColor(Color.LTGRAY); } else { tableRow.setBackgroundColor(Color.WHITE); } TextView key = new TextView(context); key.setText(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()); key.setGravity(Gravity.LEFT); TextView value = new TextView(context); value.setGravity(Gravity.RIGHT); if (jsonElement.getAsJsonObject().get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()) .toString().contains("\"")) { value.setText(jsonElement.getAsJsonObject() .get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()).toString() .replace("\"", "")); } else { value.setText(jsonElement.getAsJsonObject() .get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()).toString()); } tableRow.addView(key, new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); tableRow.addView(value, new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.setMargins(12, 16, 12, 16); tableLayout.addView(tableRow, layoutParams); rowIndex++; } tableLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(context, "Update Row " + tableIndex, Toast.LENGTH_SHORT).show(); } }); tableLayout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Toast.makeText(context, "Deleting Row " + tableIndex, Toast.LENGTH_SHORT).show(); BaseApiManager baseApiManager = new BaseApiManager(); DataManager dataManager = new DataManager(baseApiManager); Observable<GenericResponse> call = dataManager .removeDataTableEntry(dataTable.getRegisteredTableName(), entityId, Integer.parseInt(jsonElement.getAsJsonObject() .get(dataTable.getColumnHeaderData().get(0).getColumnName()) .toString())); Subscription subscription = call.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<GenericResponse>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(GenericResponse genericResponse) { Toast.makeText(context, "Deleted Row " + tableIndex, Toast.LENGTH_SHORT).show(); dataTableActionListener.onRowDeleted(); } }); return true; } }); View v = new View(context); v.setBackgroundColor(ContextCompat.getColor(context, R.color.black)); parentLayout.addView(tableLayout); parentLayout.addView(v, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 5)); Log.i("TABLE INDEX", "" + tableIndex); tableIndex++; } return parentLayout; }
From source file:com.windnow.StationTextActivity.java
@SuppressLint("RtlHardcoded") private void printTableRow(String line) { TableLayout tl = (TableLayout) findViewById(R.id.tableLayout); String[] words = line.split("&/"); TableRow tr = new TableRow(this); TableRow.LayoutParams params = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);//from w ww.j ava 2s . co m params.gravity = Gravity.FILL_HORIZONTAL; tr.setLayoutParams(params); TableRow.LayoutParams tvParams = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); tvParams.setMargins(0, 0, 6, 0); for (int i = words.length - 1; i >= 0; i--) { TextView txv = new TextView(this); txv.setLayoutParams(tvParams); txv.setText(words[i]); txv.setGravity(i == 0 ? Gravity.LEFT : Gravity.LEFT); tr.addView(txv, 0); } tl.addView(tr); }
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);//from ww w . j a v a 2 s . 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.acceleratedio.pac_n_zoom.FindTagsActivity.java
private void dsply_tags() { TableLayout tbl_tag_lo = (TableLayout) findViewById(R.id.tl_tag); int tag_mbr = 0; int tag_nmbr = fil_tags.length; String lst_str = ""; int row_mbr;/* ww w. j ava2 s . c o m*/ tbl_tag_lo.setAlpha(185); // - Find the search string srch_str = srch_str.trim(); boolean flg_srch_tags = !srch_str.equals(""); if (flg_srch_tags) { String[] srch_ary = srch_str.split("\\s* \\s*"); srch_str = srch_ary[srch_ary.length - 1].toLowerCase(); } // - Remove any current rows int row_nmbr = tbl_tag_lo.getChildCount(); if (row_nmbr > 0) tbl_tag_lo.removeAllViews(); for (row_mbr = 0; row_mbr < 4 && tag_mbr < tag_nmbr; row_mbr++) { TableRow tableRow = new TableRow(this); tableRow.setGravity(Gravity.CENTER); tableRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT, 1.0f)); for (int clm_mbr = 0; clm_mbr < 3; clm_mbr++) { Button btnTag = new Button(this); while (tag_mbr < tag_nmbr && (fil_tags[tag_mbr].equals("") || fil_tags[tag_mbr].equalsIgnoreCase(lst_str) || flg_srch_tags && !fil_tags[tag_mbr].toLowerCase().startsWith(srch_str))) { lst_str = fil_tags[tag_mbr]; tag_mbr++; } if (tag_mbr >= tag_nmbr) break; lst_str = fil_tags[tag_mbr]; btnTag.setText(fil_tags[tag_mbr++]); btnTag.setOnClickListener(this); btnTag.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT)); tableRow.addView(btnTag); } tbl_tag_lo.addView(tableRow); } }