List of usage examples for android.widget TableRow addView
public void addView(View child)
Adds a child view.
From source file:Main.java
/** * Add button to the layout as the left one on a row. * * @param act The running activity./*from www . ja v a 2 s . c o 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.brandroid.openmanager.fragments.DialogHandler.java
private static void fillShortcutsTable(TableLayout table) { final Context context = table.getContext(); for (int sc : MenuUtils.getMenuShortcuts(context)) { TableRow tr = new TableRow(context); TextView tv1 = new TextView(context); tv1.setGravity(Gravity.RIGHT);/*from w w w . j a v a 2 s . c o m*/ tv1.setPadding(20, 0, 20, 0); char scc = (char) (sc + ('a' - KeyEvent.KEYCODE_A)); tv1.setText("" + scc); TextView tv2 = new TextView(context); MenuItem item = MenuUtils.getMenuShortcut(sc); tv2.setText(item.getTitle()); tr.addView(tv1); tr.addView(tv2); table.addView(tr); } }
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);// w w w. j av a 2s . 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:com.jeffreyawest.weblogic.monitor.activity.display.DisplayClusterActivity.java
private View getSeparatorRow() { TableRow row = new TableRow(this); TextView sep;//from www . j a v a2 s. c om sep = new TextView(this); sep.setText("---"); row.addView(sep); return row; }
From source file:loonyb.in.posmachine.InvoiceFragment.java
private TableRow itemsHeader() { Context c = getActivity();//from w ww .ja v a 2 s. c o m 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: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);/*from www . j ava 2 s.c om*/ } }
From source file:com.chess.genesis.dialog.GamePoolDialog.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle("Game Pool Info"); setBodyView(R.layout.dialog_gamepool); setButtonTxt(R.id.cancel, "Close"); final TableLayout table = (TableLayout) findViewById(R.id.layout01); final LayoutParams layout = (TableRow.LayoutParams) findViewById(R.id.left).getLayoutParams(); for (final PoolDataItem item : data) { final TableRow row = new TableRow(context); TextView txt = new TextView(context); txt.setLayoutParams(layout);/*from www . j av a 2s . co m*/ txt.setText(item.gametype); row.addView(txt); txt = new TextView(context); txt.setText(item.time); row.addView(txt); table.addView(row); } }
From source file:com.photocitygame.android.ImageActivity.java
private void addScoreRow(TableLayout scoreTable, String team, int score) { TableRow row = new TableRow(this); TextView tv = new TextView(this); tv.setText(team);/*from w w w . j a va2s. c o m*/ row.addView(tv); TextView scoreView = new TextView(this); scoreView.setText(Integer.toString(score)); scoreView.setGravity(Gravity.RIGHT); row.addView(scoreView); scoreTable.addView(row); }
From source file:nl.openkvk.MainActivity.java
private void print(TableLayout tl, String l, String v) { if (v != null) { TextView v1 = new TextView(this); v1.setText(l);/* w w w . j a va 2 s.c o m*/ TextView v2 = new TextView(this); v2.setText(v.toString()); TableRow tr = new TableRow(this); tr.addView(v1); tr.addView(new TextView(this)); tr.addView(v2); tl.addView(tr); } }
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);//from w w w . ja v a 2 s . c o m 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; }