List of usage examples for android.widget TableRow getChildCount
public int getChildCount()
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;/*from www . java2 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.github.akinaru.hcidebugger.activity.DescriptionActivity.java
/** * alternate between 2 colors for the description item table * * @param alt_row//from w ww . ja v a 2 s . 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.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(); }/*www . j ava2 s. c om*/ } }
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 ww w .j a va 2s .c om 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.mikecorrigan.trainscorekeeper.FragmentSummary.java
private void updateUi() { Log.vc(VERBOSE, TAG, "updateUi"); if (game == null) { Log.w(TAG, "updateUi: no game, this=" + this); return;// w ww . j av a 2 s . c o m } if (tableLayout == null) { Log.w(TAG, "updateUi: no table, this=" + this); return; } // Subtract one to skip the header in the allocation. final int numRows = tableLayout.getChildCount() - 1; final TableRow headerRow = (TableRow) tableLayout.getChildAt(0); final int numCols = headerRow.getChildCount(); String[] header = new String[numCols]; int[][] scores = new int[numRows][numCols]; game.getSummary(header, scores); for (int c = 0; c < numCols; c++) { TextView textView = (TextView) headerRow.getChildAt(c); textView.setText(header[c]); } for (int r = 0; r < numRows; r++) { // Add one to the row index to skip the header. final TableRow row = (TableRow) tableLayout.getChildAt(r + 1); for (int c = 0; c < numCols; c++) { TextView textView = (TextView) row.getChildAt(c); textView.setText(Integer.toString(scores[r][c])); } } }
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 ww . jav 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: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 . j a va2 s .co m } } catch (Exception e) { Log.e(TAG, "^ changeFontSize: "); } } } }
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 ww .java 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; }
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); }/*from w w w . j a 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:com.retroteam.studio.retrostudio.MeasureEditor.java
/** * Assign a note visually and in the project. * @param view//from w ww . ja va 2 s . com */ private void paintNote(View view) { com.getbase.floatingactionbutton.FloatingActionButton ptool = (com.getbase.floatingactionbutton.FloatingActionButton) findViewById( R.id.pencilTool); ImageView iview = (ImageView) view; Drawable notestatus = iview.getDrawable(); if (pencil) { if (notestatus.getConstantState().equals(ContextCompat .getDrawable(getApplicationContext(), R.drawable.note_filled).getConstantState())) { //blank all other notes in the column TableRow parent = (TableRow) iview.getParent(); TableLayout layoutparent = (TableLayout) parent.getParent(); int notedrawlen = layoutparent.getChildCount(); for (int x = 0; x < notedrawlen; x++) { TableRow noterow = (TableRow) layoutparent.getChildAt(x); for (int i = 0; i < noterow.getChildCount(); i++) { ImageView note = (ImageView) noterow.getChildAt(i); if (note.getTag(R.id.TAG_COLUMN) == iview.getTag(R.id.TAG_COLUMN)) { note.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline)); for (int n = 0; n < filledNotes.size(); n++) { int[] comp = filledNotes.get(n); if (comp[0] == (int) note.getTag(R.id.TAG_ROW) && comp[1] == (int) note.getTag(R.id.TAG_COLUMN)) { filledNotes.remove(n); } } } } } //set the drawable iview.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline)); filledNotes.remove( new int[] { (int) iview.getTag(R.id.TAG_ROW), (int) iview.getTag(R.id.TAG_COLUMN) }); // set the other notes to rests List<Integer> guiSNAPRange = (List<Integer>) iview.getTag(R.id.TAG_GUISNAPRANGE); for (int z = guiSNAPRange.get(0); z <= guiSNAPRange.get(guiSNAPRange.size() - 1); z++) { theproject.track(trackNum).measure(measureNum).replace(z, new Note(Note.REST, noteSUB)); } } else { //blank all other notes in the column TableRow parent = (TableRow) iview.getParent(); TableLayout layoutparent = (TableLayout) parent.getParent(); int notedrawlen = layoutparent.getChildCount(); for (int x = 0; x < notedrawlen; x++) { TableRow noterow = (TableRow) layoutparent.getChildAt(x); for (int i = 0; i < noterow.getChildCount(); i++) { ImageView note = (ImageView) noterow.getChildAt(i); if (note.getTag(R.id.TAG_COLUMN) == iview.getTag(R.id.TAG_COLUMN)) { note.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline)); for (int n = 0; n < filledNotes.size(); n++) { int[] comp = filledNotes.get(n); if (comp[0] == (int) note.getTag(R.id.TAG_ROW) && comp[1] == (int) note.getTag(R.id.TAG_COLUMN)) { filledNotes.remove(n); } } } } } //set the drawable iview.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.note_filled)); filledNotes .add(new int[] { (int) iview.getTag(R.id.TAG_ROW), (int) iview.getTag(R.id.TAG_COLUMN) }); //set the note in the data structure double notetype = stringToNoteDouble((String) iview.getTag(R.id.TAG_NOTE)); List<Integer> guiSNAPRange = (List<Integer>) iview.getTag(R.id.TAG_GUISNAPRANGE); for (int z = guiSNAPRange.get(0); z <= guiSNAPRange.get(guiSNAPRange.size() - 1); z++) { theproject.track(trackNum).measure(measureNum).replace(z, new Note(notetype, noteSUB)); } } } }