@Override public void onClick(View arg0) { TableRow parentTableRow = (TableRow) arg0.getParent(); TableLayout parentTableLayout = (TableLayout) parentTableRow.getParent(); int index = parentTableLayout.indexOfChild(parentTableRow); // Getting The String of the removed TextView parentTextView = (TextView) parentTableRow.getChildAt(0); String parentString = parentTextView.getText().toString(); parentTableLayout.removeViewAt(index); if (parentTableLayout == adSearchMustTableLayout) { mustTermsCount--; mustTerms.remove(parentString); if (mustTermsCount == 0) { adSearchMustTableLayout.removeViewAt(0); mustTermsPresent = false; } } if (parentTableLayout == adSearchNotTableLayout) { notTermsCount--; notTerms.remove(parentString); if (notTermsCount == 0) { adSearchNotTableLayout.removeViewAt(0); notTermsPresent = false; } } if (parentTableLayout == adSearchWebsiteTebleLayout) { adSearchWebsiteTebleLayout.removeAllViews(); websitePresent = false; websiteToSearch = ""; } }
private void newGame(int c, int r) { ROW_COUNT = r; COL_COUNT = c; cards = new int[COL_COUNT][ROW_COUNT]; mainTable.removeView(findViewById(R.id.TableRow01)); mainTable.removeView(findViewById(R.id.TableRow02)); TableRow tr = ((TableRow) findViewById(R.id.TableRow03)); tr.removeAllViews(); mainTable = new TableLayout(context); tr.addView(mainTable); for (int y = 0; y < ROW_COUNT; y++) { mainTable.addView(createRow(y)); } firstCard = null; loadCards(); turns = 0; ((TextView) findViewById(R.id.tv1)).setText("ចននបកលង: " + turns); }
private void addHeader() { TableRow rowHeader = new TableRow(getActivity().getBaseContext()); TextView lblNim = new TextView(getActivity().getBaseContext()), lblNama = new TextView(getActivity().getBaseContext()); lblNim.setText("NIM"); lblNama.setText("Nama"); Float pixel1 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 120, r.getDisplayMetrics()); Float pixel2 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 260, r.getDisplayMetrics()); lblNim.setGravity(Gravity.CENTER_HORIZONTAL); lblNama.setGravity(Gravity.CENTER_HORIZONTAL); TableRow.LayoutParams param = new TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT, 1f); lblNama.setLayoutParams(param); lblNim.setLayoutParams(param); lblNim.setWidth(Math.round(pixel1)); lblNama.setWidth(Math.round(pixel2)); lblNim.setTextColor(Color.BLACK); lblNama.setTextColor(Color.BLACK); rowHeader.addView(lblNim); rowHeader.addView(lblNama); tblDaftarMhs.addView(rowHeader); }
private TableRow createTableRow() { TableRow row = new TableRow(getContext()); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); row.setLayoutParams(params); return row; }
@Override protected void onCreate() { // inflate layout LayoutInflater inflater = (LayoutInflater) this.anchor.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.popup_grid_layout, null); // setup button events for (int i = 0, icount = root.getChildCount(); i < icount; i++) { View v = root.getChildAt(i); if (v instanceof TableRow) { TableRow row = (TableRow) v; for (int j = 0, jcount = row.getChildCount(); j < jcount; j++) { View item = row.getChildAt(j); if (item instanceof Button) { Button b = (Button) item; b.setOnClickListener(this); } } } } // set the inflated view as what we want to display this.setContentView(root); }
private void addTableRow(String key, String val) { TableLayout tl = (TableLayout) findViewById(R.id.data_table); TableRow tr = new TableRow(this); MarginLayoutParams params = new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.setMargins(TABLE_ROW_MARGIN, TABLE_ROW_MARGIN, TABLE_ROW_MARGIN, TABLE_ROW_MARGIN); tr.setLayoutParams(params); tr.setBackgroundColor(Color.BLACK); TextView name = new TextView(this); name.setGravity(Gravity.RIGHT); name.setText(key + ": "); TextView value = new TextView(this); value.setGravity(Gravity.LEFT); value.setText(val); tr.addView(name); tr.addView(value); tl.addView( tr, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); /* * TODO remove this hack * * let's define a limit number of rows */ if (tl.getChildCount() > 10) tl.removeViewAt(0); }
public void start() { setContentView(R.layout.game_matrix_layout); matrika = new ImageButton[vrstice][stolpci]; TableLayout tlMatrika = (TableLayout) findViewById(R.id.tableLayoutMatrika); for (int i = 0; i < vrstice; i++) { TableRow tr = new TableRow(this); tlMatrika.addView(tr); for (int j = 0; j < stolpci; j++) { final int vrstica = i; final int stolpec = j; final ImageButton ib = new ImageButton(this); ib.setAdjustViewBounds(true); ib.setImageResource(R.drawable.blank); ib.setMaxHeight(60); ib.setScaleType(ScaleType.CENTER_INSIDE); matrika[i][j] = ib; ib.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { pozicijaVrstica = vrstica; pozicijaStolpec = stolpec; } }); tr.addView(ib); } } NIgra ni = new NIgra(this, matrika, mHandler, msgHandler); ni.start(); }
@Override protected void onResume() { super.onResume(); CustomElementManager.refresh(this); ArrayList<CustomElement> elements = CustomElementManager.getElementList(); // Clear the existing list TableLayout tl = (TableLayout) findViewById(R.id.loads_container); tl.removeAllViews(); // Go through and find all the save files and dynamically add them int length = elements.size(); if (length != 0) { for (int i = 0; i < length; i++) { addEntity(elements.get(i).getName(), elements.get(i).getFilename()); } } else { tr = new TableRow(this); tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); tr.setGravity(Gravity.CENTER); TextView tv = new TextView(this); tv.setText(res.getText(R.string.no_elements)); tr.addView(tv); tl.addView(tr); } }
private void addItem(TableLayout table, String item) { int p = item.indexOf("="); if (p < 0) return; String name = item.substring(0, p).trim(); String value = item.substring(p + 1).trim(); if (name.length() == 0 || value.length() == 0) return; boolean isSection = false; if ("section".equals(name)) { name = ""; Integer id = mLabelMap.get(value); if (id == null) return; String section = getContext().getString(id); if (section != null) value = section; isSection = true; } else { Integer id = mLabelMap.get(name); String title = id != null ? getContext().getString(id) : name; if (title != null) name = title; } TableRow tableRow = (TableRow) mInflater.inflate( isSection ? R.layout.book_info_section : R.layout.book_info_item, null); TextView nameView = (TextView) tableRow.findViewById(R.id.name); TextView valueView = (TextView) tableRow.findViewById(R.id.value); nameView.setText(name); valueView.setText(value); table.addView(tableRow); }
public void delRecord(Integer index, TableRow row1, TextView cp1) { final TextView cp = cp1; final Integer i = index; final TableRow row = row1; row.setOnLongClickListener( new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { cp.setBackgroundResource(R.drawable.borders_black_and_darkblue); AlertDialog dialog = new AlertDialog.Builder(getContext()) .setTitle("刪除記錄?") .setMessage("刪除記錄?") .setPositiveButton( android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dataAdapter1.delWord(wordRecordArrayList.get(i).getC_id()); setWordList(); } }) .setNegativeButton( R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { cp.setBackgroundResource(R.drawable.borders_black_and_blue); } }) .show(); return false; } }); }
private TableRow createRow( RowId rowId, String label, String defaultValue, String btnText, View.OnClickListener btnListener) { TableRow tb = new TableRow(this); TextView labelText = new TextView(this); TextView valueText = new TextView(this); Button btn = new Button(this); labelText.setText(label); valueText.setText(defaultValue); btn.setText(btnText); btn.setOnClickListener(btnListener); tb.addView(labelText); tb.addView(valueText); tb.addView(btn); mRowIdButtonMap.put(rowId, btn); mRowIdValueTextViewMap.put(rowId, valueText); mViewRowIdMap.put(btn, rowId); return tb; }
private TableRow createByProductRow(dbProduct product, int onboard) { try { CrashReporter.leaveBreadcrumb("MyStockSummary : createByProductRow"); // Create new row to show product stock on truck. TableRow row = (TableRow) inflater.inflate(R.layout.stock_summary_by_product_tablerow, null); row.setTag(product); // In the row set the cell showing the name of the product MyTextView productName = (MyTextView) row.findViewById(R.id.stock_summary_by_product_tablerow_product); productName.setText(product.Desc); // In the row set the cell showing the amount of product on board the truck MyTextView productOnboard = (MyTextView) row.findViewById(R.id.stock_summary_by_product_tablerow_onboard); productOnboard.setText(formatDecimal.format(onboard)); // In the row set the cell showing the volume of surplus product MyTextView surplusProduct = (MyTextView) row.findViewById(R.id.stock_summary_by_product_tablerow_to_load); surplusProduct.setText(formatDecimal.format(0)); // Add the newly created row to the table byProductTable.addView(row); return row; } catch (Exception e) { CrashReporter.logHandledException(e); return null; } }
private void initGameBoard() { mTableLayout = (TableLayout) findViewById(R.id.table_layout); mTableLayout.setStretchAllColumns(true); // mTableLayout.setBackgroundResource(R.color.blue); int counter = 1; for (int row = 0; row < 3; row++) { TableRow tableRow = new TableRow(this); for (int col = 0; col < 3; col++) { Button button = new Button(this); button.setTag(counter); // button.setText(row+","+col+"\nTag:"+button.getTag()); button.setOnClickListener(this); button.setWidth(300); button.setHeight(300); button.setTextSize(40); tableRow.addView(button); counter++; } mTableLayout.addView(tableRow, new TableLayout.LayoutParams(FP, WC)); } }
public void setAllPlayers(List<Player> allPlayers) { allPlayersTable.removeAllViews(); for (final Player player : allPlayers) { TableRow playerRow = new TableRow(context); playerRow.setLayoutParams( new TableRow.LayoutParams( TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); allPlayersTable.addView(playerRow); CheckBox playerSelection = new CheckBox(context); playerSelection.setChecked(player.isSelected()); playerSelection.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isCurrentPlayerSelected = isChecked; currentPlayerId = player.getId(); selectedPlayersChangedListenerManager.notifyListeners(); } }); playerRow.addView(playerSelection); TextView playerName = new TextView(context); playerName.setText(player.getName()); playerName.setTextSize(UIConstants.TEXT_NORMAL_SIZE); playerName.setTextColor(UIConstants.TEXT_COLOR); playerRow.addView(playerName); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.repeat_dialog); setTitle(REPEAT); repeatRepEdit = (EditText) findViewById(R.id.repeatRepEdit); repeatUntilDate = (TextView) findViewById(R.id.repeatUntilDate); repeatRepEdit.setOnClickListener(this); repeatUntilDate.setOnClickListener(this); repeatRepRow = (TableRow) findViewById(R.id.repeatRepRow); repeatUntilRow = (TableRow) findViewById(R.id.repeatUntilRow); repeatRepRow.setOnClickListener(this); repeatUntilRow.setOnClickListener(this); repeatRepRadio = (RadioButton) findViewById(R.id.repeatRepRadio); repeatUntilRadio = (RadioButton) findViewById(R.id.repeatUntilRadio); repeatRepRadio.setOnClickListener(this); repeatUntilRadio.setOnClickListener(this); yes = (Button) findViewById(R.id.btn_yes); no = (Button) findViewById(R.id.btn_no); yes.setOnClickListener(this); no.setOnClickListener(this); if (null != rule && rule.getUntil() == null && rule.getCount() == null) { repeatRepEdit.performClick(); repeatRepEdit.setText("1"); } }
/** * -=========================================/ generateOutput() -- Fill R.id.numberBox with bases * and squares and cubes. Note that this method simply assumes that start >= end. This should * always be the case, as setLimits() does this error checking. * /==========================================- */ private void generateOutput(int start, int end) { ViewGroup.LayoutParams widthHeightSettings = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); // I will later pass this object to TableRows (as they are created) to define their width and // height. TableLayout numberContainer = (TableLayout) findViewById(R.id.numberBox); numberContainer.removeAllViews(); int row, column; Context appContext = getApplicationContext(); for (row = 0; row <= (end - start); row++) { // Create a TableRow row. TableRow aRow = new TableRow(appContext); aRow.setId(row); aRow.setLayoutParams(widthHeightSettings); numberContainer.addView(aRow); for (column = 0; column < 3; column++) { // Create a TextView column, and place it in the just-created TableRow row. TextView aNumber = new TextView(appContext); // aNumber.setLayoutParams(widthHeightSettings); // Fails. I don't know why. aNumber.setText(Double.toString(Math.pow(start + row, 1 + column))); ((TableRow) numberContainer.findViewById(row)).addView(aNumber); } } }
@Override protected void onPostExecute(Void v) { Log.d("RAWR", "Table Shiz"); TableLayout tl = (TableLayout) findViewById(R.id.table); for (int i = 0; i < labels.size(); i++) { TableRow tr = new TableRow(getApplicationContext()); TextView t1 = new TextView(getApplicationContext()); t1.setText(labels.get(i)); t1.setTextColor(Color.BLACK); t1.setTypeface(null, Typeface.BOLD); tr.addView(t1); TextView t2 = new TextView(getApplicationContext()); t2.setText(data.get(i)); t2.setGravity(Gravity.RIGHT); t2.setTextColor(Color.BLACK); tr.addView(t2); tl.addView( tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); } TextView desc = (TextView) findViewById(R.id.description); desc.setText("Description: \n\n\t" + description); pd.dismiss(); }
public TableRow createRow(String rowName, String rowValue, int colour) { TableRow tableRow = new TableRow(context); tableRow.setLayoutParams( new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); TextView textView = new TextView(context); textView.setText(rowName); textView.setTextColor(colour); textView.setTextSize(20.0f); TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(0); layoutParams.width = 175; textView.setLayoutParams(layoutParams); TextView textViewValue = new TextView(context); textViewValue.setText(rowValue); textViewValue.setTextColor(colour); textViewValue.setTextSize(20.0f); textViewValue.setGravity(Gravity.RIGHT); textViewValue.setLayoutParams(new TableRow.LayoutParams(1)); tableRow.addView(textView); tableRow.addView(textViewValue); return tableRow; }
/** * Appends a swatch to the end of the row for even-numbered rows (starting with row 0), to the * beginning of a row for odd-numbered rows. */ private static void addSwatchToRow(TableRow row, View swatch, int rowNumber) { if (rowNumber % 2 == 0) { row.addView(swatch); } else { row.addView(swatch, 0); } }
private void addByCompartment(dbProduct product, int compartment, int capacity, int onboard) { try { TableRow tr = (TableRow) inflater.inflate(R.layout.stock_summary_by_compartment_tablerow, null); MyTextView tvNo = (MyTextView) tr.findViewById(R.id.stock_summary_by_compartment_tablerow_no); tvNo.setText(compartment == 0 ? "Line" : "#" + compartment); if (product != null) { MyTextView tvProduct = (MyTextView) tr.findViewById(R.id.stock_summary_by_compartment_tablerow_product); tvProduct.setText(product.Desc); } if (capacity != 0) { MyTextView tvCapacity = (MyTextView) tr.findViewById(R.id.stock_summary_by_compartment_tablerow_capacity); tvCapacity.setText(formatDecimal.format(capacity)); } if (onboard != 0) { MyTextView tvOnboard = (MyTextView) tr.findViewById(R.id.stock_summary_by_compartment_tablerow_onboard); tvOnboard.setText(formatDecimal.format(onboard)); } tlByCompartmentTable.addView(tr); } catch (Exception e) { CrashReporter.logHandledException(e); } }
private void resetButton(TableRow row) { Resources resource = getApplicationContext().getResources(); row.setBackgroundColor(Color.TRANSPARENT); // make the background transparent TextView tv = (TextView) row.getChildAt(0); tv.setTextColor(resource.getColor(R.color.white)); // tv.setTextColor(resource.getColor(R)); }
@Override public View getView(final int position, View view, ViewGroup parent) { if (view == null) view = getLayoutInflater().inflate(R.layout.list_single, null, false); final ElementManager currentElement = elementsList.get(position); TableRow tableRow = (TableRow) view.findViewById(R.id.tablerow); tableRow.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Bundle bundle = new Bundle(); bundle.putInt("advertid", currentElement.getId()); Intent detail = new Intent(IlanAraActivity.this, IlanActivity.class); detail.putExtras(bundle); startActivity(detail); } }); TextView section = (TextView) view.findViewById(R.id.section); TextView location = (TextView) view.findViewById(R.id.location); TextView price = (TextView) view.findViewById(R.id.price); section.setText(currentElement.getBaslik()); location.setText(currentElement.getKonum()); price.setText(currentElement.getFiyat()); ImageView img = (ImageView) view.findViewById(R.id.img); Basic b = new Basic(); Bitmap map = b.decompressImage(currentElement.getResim()); img.setScaleType(ImageView.ScaleType.FIT_XY); img.setImageBitmap(map); return view; }
public void addTableBody(TableLayout table) { Cursor cursor = mySQLiteHelper.executeQuery(this.buildTableQuery()); int row = 0; if (cursor != null && cursor.moveToFirst()) { do { TableRow tr = new TableRow(getActivity()); tr.setGravity(Gravity.CENTER); for (int i = 0; i < columnNames.length; i++) { String value = cursor.getString(cursor.getColumnIndex(columnNames[i])); TextView tv = getCellTextView(value, row); tr.addView(tv); } table.addView(tr); Long id = cursor.getLong(cursor.getColumnIndex("_id")); tr.setTag(id); tr.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Long id = Long.valueOf(v.getTag().toString()); String xml = formBuilder.buildFormSubmissionXMLString(form, id); ((FormDataActivity) getActivity()).switchToDisplayFormFragment(1, xml); } }); row++; } while (cursor.moveToNext()); } }
public void init() { TableLayout attendanceTable = (TableLayout) findViewById(R.id.attendanceTableLayout); CheckBox checkBox; TextView tv; ImageButton addBtn; for (int i = 0; i < 2; i++) { TableRow row = new TableRow(this); TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT); row.setLayoutParams(lp); checkBox = new CheckBox(this); tv = new TextView(this); addBtn = new ImageButton(this); addBtn.setImageResource(R.drawable.student_pic); addBtn.setMaxWidth(10); addBtn.setMaxHeight(10); checkBox.setText("Mark: "); tv.setText("Student " + i); row.addView(checkBox); row.addView(tv); row.addView(addBtn); attendanceTable.addView(row, i); } }
public void bindView(Cursor cursor) { // Reinflate layout removeAllViewsInLayout(); View view = LayoutInflater.from(getContext()).inflate(R.layout.sets_table, this); TableRow tableRowWeight = (TableRow) view.findViewById(R.id.tableRowWeight); TableRow tableRowReps = (TableRow) view.findViewById(R.id.tableRowReps); if (cursor != null && cursor.moveToFirst()) { do { TextView textViewWeight = new TextView(getContext()); TextView textViewReps = new TextView(getContext()); textViewWeight.setBackgroundResource(R.drawable.cell_right_border); textViewReps.setBackgroundResource(R.drawable.cell_right_top_border); textViewWeight.setPadding(4, 0, 5, 0); textViewReps.setPadding(4, 0, 5, 0); textViewWeight.setGravity(Gravity.CENTER_HORIZONTAL); textViewReps.setGravity(Gravity.CENTER_HORIZONTAL); tableRowWeight.addView(textViewWeight); tableRowReps.addView(textViewReps); // Bind data float weight = cursor.getFloat(cursor.getColumnIndex(Sets.WEIGHT)); String reps = cursor.getString(cursor.getColumnIndex(Sets.REPS)); textViewWeight.setText(SetUtils.weightFormat(weight)); textViewReps.setText(reps); } while (cursor.moveToNext()); } }
protected void initBoard() { numericBoardView = new TableLayout(this); imageBoardView = new TableLayout(this); final Board board = getBoardModel(); board.addMoveListener(this); final int boardSize = getBoardSize(); numericCells = new TextView[boardSize][boardSize]; imageCells = new ImageView[boardSize][boardSize]; for (int i = 0; i < boardSize; i++) { TableRow numericRow = new TableRow(this); TableRow imageRow = new TableRow(this); for (int j = 0; j < boardSize; j++) { TextView numericCell = new TextView(this); ImageView imageCell = new ImageView(this); numericCells[i][j] = numericCell; imageCells[i][j] = imageCell; initNumericCell(numericCell); initImageCell(imageCell); numericRow.addView(numericCell); imageRow.addView(imageCell); } numericBoardView.addView(numericRow); imageBoardView.addView(imageRow); } countDownCell = new TextView(this); initNumericCell(countDownCell); }
private void uiAddModeRow(TableLayout tl) { TableRow tb = new TableRow(this); TextView labelText = new TextView(this); Button btnDay = new Button(this); Button btnNight = new Button(this); Button btnMedia = new Button(this); Button btnFirmware = new Button(this); labelText.setText("Mode:"); btnDay.setText("Day"); btnNight.setText("Night"); btnMedia.setText("Media"); btnFirmware.setText("Firmware"); btnDay.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mBtBand.addRequest( BtAction.Action.SET_MODE, BandMode.getInt(BandMode.AccessoryMode.DAY)); } }); btnNight.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mBtBand.addRequest( BtAction.Action.SET_MODE, BandMode.getInt(BandMode.AccessoryMode.NIGHT)); } }); btnMedia.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mBtBand.addRequest( BtAction.Action.SET_MODE, BandMode.getInt(BandMode.AccessoryMode.MEDIA)); } }); btnFirmware.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mBtBand.addRequest( BtAction.Action.SET_MODE, BandMode.getInt(BandMode.AccessoryMode.FIRMWARE_UPDATE)); } }); tb.addView(labelText); tb.addView(btnDay); tb.addView(btnNight); tb.addView(btnMedia); tb.addView(btnFirmware); tl.addView(tb); }
public void onClick(View v) { TableRow tableRow = (TableRow) v.getParent(); TextView tucTextView = (TextView) tableRow.findViewById(R.id.tucId); String tucId = tucTextView.getText().toString(); //// System.out.println("Try Deleting tuc "+tucId+" ++ "+tableRow.getChildCount()); deleteOneTuc(tucId); }
public TableLayout createTable() { int comboCounter = 0; TableLayout tl = new TableLayout(this); TableRow tr = new TableRow(this); CheckBox c; TextView text; for (int x = 0; x < KMapControl.getTopDisplay().length; x++) { text = new TextView(this); if (KMapControl.getKMapSize() == KMapController.VARIABLE_5) { if (x == 0) { fiveVarCounter += 1; text.setTextColor(Color.YELLOW); text.setText(fiveVarCounter + " "); } else text.setText(KMapControl.getTopDisplay()[x]); } else { text.setText(KMapControl.getTopDisplay()[x]); } text.setPadding(PADDING, PADDING, PADDING, PADDING); tr.addView(text); } tl.addView(tr); for (int x = 0; x < KMapControl.getLeftDisplay().length; x++) { tr = new TableRow(this); text = new TextView(this); text.setText(KMapControl.getLeftDisplay()[x]); text.setPadding(PADDING, PADDING, PADDING, PADDING); tr.addView(text); for (int y = 1; y < KMapControl.getTopDisplay().length; y++) { c = new CheckBox(this); if (KMapControl.getKMapSize() == KMapController.VARIABLE_5 && fiveVarCounter == 1) c.setId(KMapControl.getTableLayout()[comboCounter] + 16); else c.setId(KMapControl.getTableLayout()[comboCounter]); c.setButtonDrawable(R.drawable.customcheck); c.setPadding(PADDING, PADDING, PADDING, PADDING); c.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean arg1) { KMapControl.setVariableAtLocation(arg0.getId(), arg1); String s = "\nLast Selected:\n\nMinterm: " + arg0.getId() + "\n" + "State: "; if (arg1 == false) s += "0"; else s += "1"; s += "\nBinary: " + KMapControl.getBinarySpot(arg0.getId()); s += "\nVariables: " + KMapControl.getStringVariableAtLocation(arg0.getId()); display.setText(s); } }); tr.addView(c); comboCounter += 1; } tl.addView(tr); } return tl; }
private TableRow createRow(int y) { TableRow row = new TableRow(context); row.setHorizontalGravity(Gravity.CENTER); for (int x = 0; x < COL_COUNT; x++) { row.addView(createImageButton(x, y)); } return row; }