List of usage examples for android.widget TableRow getChildAt
public View getChildAt(int index)
From source file:Main.java
/** * Add button to the layout as the right one on a row * * @param theRow The row the button will be added to. * @param actName Name of the activity./* w w w . ja v a 2 s . com*/ * @return The Button object that is constructed. */ private static Button addButtonAsSecond(TableRow theRow, String actName) { /** * Get the second button. Set text and visibility. */ Button btn = (Button) theRow.getChildAt(1); btn.setText(actName); btn.setVisibility(View.VISIBLE); return btn; }
From source file:Main.java
/** * Add button to the layout as the left one on a row. * * @param act The running activity./*from ww w .j a v a2s . 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:com.svpino.longhorn.artifacts.StockTileProcessor.java
private static boolean shouldUpdateTableRow(TableLayout tableLayout, int row, Stock stock1, Stock stock2) { boolean shouldUpdateTableRow = true; TableRow currentTableRow = (TableRow) tableLayout.getChildAt(row); if (currentTableRow != null) { StockTileViewHolder tile1 = (StockTileViewHolder) currentTableRow.getChildAt(0).getTag(); StockTileViewHolder tile2 = currentTableRow.getChildCount() == 2 ? (StockTileViewHolder) currentTableRow.getChildAt(1).getTag() : null;/* ww w. ja v a 2 s. c om*/ if (tile1 != null && (stock2 == null || tile2 != null)) { if (tile1.getStock().equals(stock1)) { if (stock2 != null && tile2.getStock().equals(stock2)) { shouldUpdateTableRow = false; } else if (stock2 == null && tile2 == null) { shouldUpdateTableRow = false; } } } } return shouldUpdateTableRow; }
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();/*w w w .j a v a 2 s . c o m*/ 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:de.domjos.schooltools.activities.MainActivity.java
public static void initTimes(TableLayout grid) { Map<Double, Hour> times = new TreeMap<>(); List<Hour> hours = MainActivity.globals.getSqLite().getHours(""); for (Hour hour : hours) { times.put(Double.parseDouble(hour.getStart().replace(":", ".")), hour); }/* w ww .j a v a 2 s .c o m*/ List hourList = Arrays.asList(times.values().toArray()); int max = hourList.size() - 1; for (int i = 1; i <= grid.getChildCount() - 1; i++) { TableRow row = (TableRow) grid.getChildAt(i); TextView textView = (TextView) row.getChildAt(0); if ((i - 1) <= max) { Hour hour = (Hour) hourList.get(i - 1); textView.setText(String.format("%s%n%s", hour.getStart(), hour.getEnd())); textView.setTag(String.valueOf(hour.getID())); if (hour.isBreak()) { textView.setTextSize(14); textView.setText(textView.getText().toString().replace("\n", ":")); for (int j = 1; j <= row.getChildCount() - 1; j++) { row.getChildAt(j).setBackgroundColor(Color.TRANSPARENT); row.setBackgroundResource(R.drawable.tbl_border); } } } else { grid.getChildAt(i).setVisibility(View.GONE); } } }
From source file:com.dicent.DiceFragment.java
public void redraw() { TableLayout tl = (TableLayout) getView().findViewById(R.id.diceTable); for (int i = 0; i < tl.getChildCount(); i++) { // table rows TableRow row = (TableRow) tl.getChildAt(i); for (int j = 0; j < row.getChildCount(); j++) { // dice row.getChildAt(j).invalidate(); }//from w w w .j a v a 2 s.c o m } }
From source file:com.github.akinaru.hcidebugger.activity.DescriptionActivity.java
/** * alternate between 2 colors for the description item table * * @param alt_row//from w w w . j a v a2s. c o m */ public void altTableRow(int alt_row) { int childViewCount = tablelayout.getChildCount(); for (int i = 0; i < childViewCount; i++) { TableRow row = (TableRow) tablelayout.getChildAt(i); for (int j = 0; j < row.getChildCount(); j++) { TextView tv = (TextView) row.getChildAt(j); if (i % alt_row != 0) { tv.setBackground(getResources().getDrawable(R.drawable.alt_row_color)); } else { tv.setBackground(getResources().getDrawable(R.drawable.row_color)); } } } }
From source file:com.cybrosys.basic.BasicActivity.java
@Override public void onStart() { super.onStart(); getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); ctx = getActivity();/*from w ww . j a va 2 s. c o m*/ init(); mDisplay = (CalculatorDisplay) getView().findViewById(R.id.display); imm = (InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE); mDisplay = (CalculatorDisplay) getView().findViewById(R.id.display); mPersist = new Persist(ctx); mPersist.load(); mHistory = mPersist.history; mLogic = new Logic(ctx, mHistory, mDisplay); mLogic.setDeleteMode(mPersist.getDeleteMode()); mLogic.setLineLength(mDisplay.getMaxDigits()); HistoryAdapter historyAdapter = new HistoryAdapter(ctx, mHistory, mLogic); mHistory.setObserver(historyAdapter); mListener.setHandler(mLogic, mPager); mDisplay.setOnKeyListener(mListener); btnmul = (Button) getView().findViewById(R.id.btnmul); btnmul.setText(Html.fromHtml("x")); btnminus = (Button) getView().findViewById(R.id.btnminus); btnminus.setText(Html.fromHtml("-")); // tablelayout of numbers TableLayout tblltPad = (TableLayout) getView().findViewById(R.id.tabcalc); int inPadCount = tblltPad.getChildCount(); for (int inI = 0; inI < inPadCount; inI++) { View vwView = tblltPad.getChildAt(inI); if (vwView instanceof TableRow) { TableRow tblrRow = (TableRow) vwView; int inRowCount = tblrRow.getChildCount(); for (int inR = 0; inR < inRowCount; inR++) { View v2 = tblrRow.getChildAt(inR); if (v2 instanceof Button) { Button b = (Button) v2; if (b.getId() == R.id.buttonDel) { b.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { mLogic.onClear(); return true; } }); } // setting on click listener for the buttons b.setOnClickListener(mListener); } } } } mDisplay.setText(myString, null); }
From source file:com.cybrosys.scientific.ScientificActivity.java
@Override public void onStart() { super.onStart(); getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); ctx = getActivity();/*from w w w.j a v a 2 s .co m*/ init(); mDisplay = (CalculatorDisplay) getView().findViewById(R.id.display); imm = (InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE); mDisplay = (CalculatorDisplay) getView().findViewById(R.id.display); metrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); inDispheight = (int) (metrics.heightPixels * .6f); inDispwidth = (int) (metrics.widthPixels * .8f); mPersist = new Persist(ctx); mPersist.load(); mHistory = mPersist.history; mLogic = new Logic(ctx, mHistory, mDisplay); mLogic.setDeleteMode(mPersist.getDeleteMode()); mLogic.setLineLength(mDisplay.getMaxDigits()); HistoryAdapter historyAdapter = new HistoryAdapter(ctx, mHistory, mLogic); mHistory.setObserver(historyAdapter); mListener.setHandler(mLogic, mPager); mDisplay.setOnKeyListener(mListener); // tablelayout for the functions TableLayout tblltPad = (TableLayout) getView().findViewById(R.id.tableLayout1); int inPadCount = tblltPad.getChildCount(); for (int inI = 0; inI < inPadCount; inI++) { View vwView = tblltPad.getChildAt(inI); if (vwView instanceof TableRow) { TableRow tblrRow = (TableRow) vwView; int inRowCount = tblrRow.getChildCount(); for (int inR = 0; inR < inRowCount; inR++) { View v2 = tblrRow.getChildAt(inR); if (v2 instanceof Button) { Button b = (Button) v2; // setting listeners for the function buttons b.setOnClickListener(mListener); b.setOnLongClickListener(mListener); } else if (v2 instanceof TextView) { TextView txtv = (TextView) v2; txtv.setOnClickListener(null); } } } } // tablelayout for the numbers TableLayout tblltNum = (TableLayout) getView().findViewById(R.id.tableLayout2); int inNumcount = tblltNum.getChildCount(); mDisplay.setText(myString, null); txtvFSE.setText(strFSEstate); txtvShift.setText(strAlt); txtvDeg.setText(strDeg); txtvHyp.setText(strHyp); for (int inI = 0; inI < inNumcount; inI++) { View vw1 = tblltNum.getChildAt(inI); if (vw1 instanceof TableRow) { TableRow tblrRow = (TableRow) vw1; int inRowCount = tblrRow.getChildCount(); for (int inR = 0; inR < inRowCount; inR++) { View vw2 = tblrRow.getChildAt(inR); if (vw2 instanceof Button) { Button b = (Button) vw2; // setting listeners for the buttons b.setOnClickListener(mListener); b.setOnLongClickListener(mListener); } else if (vw2 instanceof TextView) { TextView txtv = (TextView) vw2; txtv.setOnClickListener(null); } } } } }
From source file:com.uoit.freeroomfinder.Results.java
/** * SetupUpTableView Set all the default values for the table view and instantiate handles to the * interface elements./*from w w w . ja v a 2 s . c o m*/ * * @param inflater The inflater for the layout. * @param container The ViewGroup container for the view. * @param index The index for the table view. * * @return Returns a handle to the first table row. */ public TableRow SetupUpTableView(LayoutInflater inflater, ViewGroup container, final int index) { View newView = inflater.inflate(R.layout.room_item, container, false); TextView room = (TextView) newView.findViewById(R.id.room); TextView start = (TextView) newView.findViewById(R.id.stime); TextView end = (TextView) newView.findViewById(R.id.etime); RadioButton ch = (RadioButton) newView.findViewById(R.id.radio_button); // Provides the logic for the selectable table rows. ch.setOnClickListener(new OnClickListener() { /* * (non-Javadoc) * * @see android.view.View.OnClickListener#onClick(android.view.View) */ @Override public void onClick(View v) { RadioButton rb = (RadioButton) v; // A different row has been selected. if (checked != rb) { // Check if it's been checked the first time. if (checked != null) { checked.setChecked(false); } checked = rb; rb.setChecked(true); isNotChecked = false; } // The same row has been selected. else if (checked == rb) { rb.setChecked(isNotChecked); checked = rb; v = (View) rb; isNotChecked = !isNotChecked; } // Prepare the button if a row is selected, otherwise disable it. if (isNotChecked) { book.setEnabled(false); indexOfChecked = -1; } else { indexOfChecked = index; book.setEnabled(true); } rb.refreshDrawableState(); } }); // Grab the results and format the dates according to the values therein. Rooms first = results.get(index); room.setText(first.getRoom()); start.setText(DateTimeUtility.formatTime(new Date(first.getStartTime()))); end.setText(DateTimeUtility.formatTime(new Date(first.getEndTime()))); TableRow tr = (TableRow) newView.findViewById(R.id.room_row); // Provide the logic for selecting a table row. tr.setOnClickListener(new OnClickListener() { /* * (non-Javadoc) * * @see android.view.View.OnClickListener#onClick(android.view.View) */ @Override public void onClick(View v) { TableRow d = (TableRow) v; // Note the location of the relative layout is hard coded here as the last element in the table row. // Also, the radio button is hard coded here as the first (and only) element in the relative layout. ((RelativeLayout) d.getChildAt(d.getChildCount() - 1)).getChildAt(0).performClick(); } }); return tr; }