List of usage examples for android.widget TableLayout getChildAt
public View getChildAt(int index)
From source file:Main.java
/** * Clears all of the TableRows from a TableLayout, with the EXCEPTION * of the first row! The first row should be the component category * (Situps, Pushups, Run, Waist) and should therefore never be deleted. * @param table/* w w w .ja v a2 s . c om*/ */ public static void clearAfiTable(TableLayout table) { int count = table.getChildCount(); for (int i = 1; i < count; i++) { View child = table.getChildAt(i); if (child instanceof TableRow) ((ViewGroup) child).removeAllViews(); } }
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 w w . j a va 2 s.c om 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; }
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;/* w ww. j a v a2 s. co m*/ 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.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 a2 s . c o m*/ } }
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 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); 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:at.ac.uniklu.mobile.sportal.DashboardUpcomingDatesFragment.java
private void adjustDateListHeight() { final TableLayout dateListTable = (TableLayout) getView().findViewById(R.id.dates); // post the action to the UI thread to defer execution until the view has been drawn dateListTable.post(new Runnable() { @Override// w w w. j a va2 s .c o m public void run() { // get first row View v = dateListTable.getChildAt(0); int entryHeight; if (v != null && (entryHeight = v.getMeasuredHeight()) > 0) { int numPossibleVisibleRows = dateListTable.getMeasuredHeight() / entryHeight; int numExisitingRows = Math.min(numPossibleVisibleRows, dateListTable.getChildCount()); int numVisibleRows = Math.min(numExisitingRows, numPossibleVisibleRows); // remove rows that are outside the screen if (numExisitingRows > numVisibleRows) { dateListTable.removeViews(numVisibleRows, numExisitingRows - numVisibleRows); } // toggle visibility of rows inside the screen for (int x = 0; x < numVisibleRows; x++) { dateListTable.getChildAt(x).setVisibility(View.VISIBLE); } } else { Log.d(TAG, "cannot adjust list height"); } } }); }
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();/* www . j a v a 2s . 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); 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: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 w w . ja va 2 s. co 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:aws.apps.underthehood.Main.java
private void changeFontSize(TableLayout t, float fontSize) { for (int i = 0; i <= t.getChildCount() - 1; i++) { TableRow row = (TableRow) t.getChildAt(i); for (int j = 0; j <= row.getChildCount() - 1; j++) { View v = row.getChildAt(j); try { if (v.getClass() == Class.forName("android.widget.TextView")) { TextView tv = (TextView) v; if (i % 2 == 0) { } else { tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); }//from w w w . ja v a2 s. co m } } catch (Exception e) { Log.e(TAG, "^ changeFontSize: "); } } } }
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. co 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; } }