@Override public void onClick(View arg0) { hideSoftKeyboard(); if (adSearchMustEditText.getText().length() > 0) { LayoutInflater termsInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View termsView = termsInflater.inflate(R.layout.added_terms_layout, null); TextView newTerm = (TextView) termsView.findViewById(R.id.newTermTextView); Button newDeleteButton = (Button) termsView.findViewById(R.id.newRemoveTermButton); newDeleteButton.setOnClickListener(deleteButtonListener); // String termText = // "\""+adSearchMustEditText.getText().toString()+"\""; newTerm.setText(adSearchMustEditText.getText().toString()); // Adding to mustTerms Array; mustTerms.add(adSearchMustEditText.getText().toString()); adSearchMustEditText.setText(""); // If terms are not present if (!mustTermsPresent) { View titleView = termsInflater.inflate(R.layout.title_layout, null); TextView newTitle = (TextView) titleView.findViewById(R.id.newTitleTextView); newTitle.setText(R.string.must_title); adSearchMustTableLayout.addView(titleView); mustTermsPresent = true; // Set this value to true } adSearchMustTableLayout.addView(termsView, 1); mustTermsCount++; } }
@Override public void onClick(View arg0) { hideSoftKeyboard(); if (adSearchNotEditText.getText().length() > 0) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View notTermsView = inflater.inflate(R.layout.added_terms_layout, null); if (!notTermsPresent) { View notTitleView = inflater.inflate(R.layout.title_layout, null); TextView notTitle = (TextView) notTitleView.findViewById(R.id.newTitleTextView); notTitle.setText(R.string.not_title); adSearchNotTableLayout.addView(notTitleView); notTermsPresent = true; } TextView newTerm = (TextView) notTermsView.findViewById(R.id.newTermTextView); newTerm.setText(adSearchNotEditText.getText().toString()); Button newDeleteButton = (Button) notTermsView.findViewById(R.id.newRemoveTermButton); newDeleteButton.setOnClickListener(deleteButtonListener); // Add to the notTerms Arraylist notTerms.add(adSearchNotEditText.getText().toString()); adSearchNotEditText.setText(""); adSearchNotTableLayout.addView(notTermsView, 1); notTermsCount++; } }
protected android.view.View onCreateDialogView() { android.widget.TableLayout.LayoutParams params; android.widget.TableLayout layout = new android.widget.TableLayout(mContext); layout.setPadding(6, 6, 6, 6); mSplashText = new android.widget.TextView(mContext); if (mDialogMessage != null) { mSplashText.setText(mDialogMessage); } android.widget.TableRow row_header = new android.widget.TableRow(mContext); row_header.addView(mSplashText); mPickInteger = new net.mandaria.tippytipper.widgets.NumberPicker(mContext); mPickInteger.setRange(mMin, mMax); android.widget.TextView suffix = new android.widget.TextView(mContext); suffix.setText(mSuffix); suffix.setTextSize(32); android.widget.TableRow row_one = new android.widget.TableRow(mContext); row_one.setGravity(Gravity.CENTER); row_one.addView(mPickInteger); row_one.addView(suffix); layout.addView(row_header); android.widget.TableLayout table_main = new android.widget.TableLayout(mContext); table_main.addView(row_one); android.widget.TableRow row_main = new android.widget.TableRow(mContext); row_main.setGravity(Gravity.CENTER_HORIZONTAL); row_main.addView(table_main); layout.addView(row_main); if (shouldPersist()) { mValue = getPersistedInt(mDefault); } bindData(); return layout; }
private void populateSkillsTable() { TableLayout tableSkills = (TableLayout) findViewById(R.id.tableSkills); tableSkills.setShrinkAllColumns(false); tableSkills.setStretchAllColumns(false); tableSkills.removeAllViews(); skillEditorFactory.resetEditors(); Map<String, SkillCategoryEditor> categoryEditors = new HashMap<String, SkillCategoryEditor>(); for (ISkill skill : investigator.getSkills().list()) { if (skill.isCategory()) { SkillCategoryEditor editor = skillEditorFactory.newSkillCategoryEditor( this, investigator.getSkills(), (SkillCategory) skill); categoryEditors.put(skill.getName(), editor); editor.addOnSkillChangedListener(this); tableSkills.addView(editor); } else { Skill sk = (Skill) skill; if (sk.isAdded()) continue; SkillEditor editor = skillEditorFactory.newSkillEditor(investigator.getSkills(), sk); editor.addOnSkillChangedListener(this); tableSkills.addView(editor); } } skillChanged(null); }
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; }
@Override protected void onProgressUpdate(Void... v) { table.removeAllViewsInLayout(); if (GPIOStatus == null) return; table.addView(createRow("Pin", "Status")); for (String pin : GPIOStatus.keySet()) { table.addView(createRow(pin, GPIOStatus.get(pin))); } Log.i("INFO", "UI SHOUD BE UPDATED"); }
public void setRecentTransferModels( List<TransferObjectCard> recentTransferModel, OnSlideItemClickListener mOnSlideItemClickListener) { mItemSlideTouchListener.setOnSlideItemClickListener(mOnSlideItemClickListener); this.recentTransferModel = recentTransferModel; recent_content.removeAllViews(); { View rowItem = (View) mLayoutInflater.inflate(R.layout.bper_recent_slidelist_items, null); TextView textView1 = (TextView) rowItem.findViewById(R.id.textView1); textView1.setText(R.string.data); TextView textView2 = (TextView) rowItem.findViewById(R.id.textView2); textView2.setText(R.string.beneficiary_tilte); TextView textView4 = (TextView) rowItem.findViewById(R.id.textView4); textView4.setText(R.string.amount_h); ImageView imageView = (ImageView) rowItem.findViewById(R.id.imageView1); imageView.setVisibility(View.INVISIBLE); recent_content.addView(rowItem); ImageView divider = new ImageView(context); divider.setImageResource(R.drawable.upper_shading); recent_content.addView(divider); } if (recentTransferModel == null || recentTransferModel.size() <= 0) { return; } String currency = contentView.getContext().getResources().getString(R.string.eur); int size = recentTransferModel.size(); for (int i = 0; i < size; i++) { TransferObjectCard accountsModel = recentTransferModel.get(i); View rowItem = (View) mLayoutInflater.inflate(R.layout.bper_recent_slidelist_items, null); TextView textView1 = (TextView) rowItem.findViewById(R.id.textView1); String operationDate = TimeUtil.getDateString(accountsModel.getDate(), TimeUtil.dateFormat5); textView1.setText(operationDate); TextView textView2 = (TextView) rowItem.findViewById(R.id.textView2); String beneficiary = accountsModel.getBeneficiaryName(); if (beneficiary == null) { beneficiary = ""; } textView2.setText(beneficiary); TextView textView4 = (TextView) rowItem.findViewById(R.id.textView4); textView4.setText(Utils.notPlusGenerateFormatMoney(currency, accountsModel.getAmount())); recent_content.addView(rowItem); if (i < size - 1) { recent_content.addView(mLayoutInflater.inflate(R.layout.separation_line_divider, null)); } ViewHolder mViewHolder = new ViewHolder(); mViewHolder.init(rowItem); mViewHolder.position = i; rowItem.setTag(mViewHolder); rowItem.setOnTouchListener(mItemSlideTouchListener); } }
private void displayCall(Resources resources, LinphoneCall call, int index) { String sipUri = call.getRemoteAddress().asStringUriOnly(); LinphoneAddress lAddress; try { lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri); } catch (LinphoneCoreException e) { Log.e("Incall activity cannot parse remote address", e); lAddress = LinphoneCoreFactory.instance().createLinphoneAddress("uknown", "unknown", "unkonown"); } // Control Row LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.active_call_control_row, container, false); callView.setId(index + 1); setContactName(callView, lAddress, sipUri, resources); displayCallStatusIconAndReturnCallPaused(callView, call); setRowBackground(callView, index); registerCallDurationTimer(callView, call); callsList.addView(callView); // Image Row LinearLayout imageView = (LinearLayout) inflater.inflate(R.layout.active_call_image_row, container, false); Contact contact = ContactsManager.getInstance() .findContactWithAddress(imageView.getContext().getContentResolver(), lAddress); if (contact != null) { displayOrHideContactPicture( imageView, contact.getPhotoUri(), contact.getThumbnailUri(), false); } else { displayOrHideContactPicture(imageView, null, null, false); } callsList.addView(imageView); callView.setTag(imageView); callView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (v.getTag() != null) { View imageView = (View) v.getTag(); if (imageView.getVisibility() == View.VISIBLE) imageView.setVisibility(View.GONE); else imageView.setVisibility(View.VISIBLE); callsList.invalidate(); } } }); }
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); } }
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); }
private void addHeadline(TableLayout table) { TextView tv; TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.treatments_header, null); tv = (TextView) tr.findViewById(R.id.treatment_header_medicament_name); tv.setText("Medicine name"); tv.setTextColor(Color.BLACK); tv.setTextSize(18); tv = (TextView) tr.findViewById(R.id.treatment_header_treatment_frequency); tv.setText("Frequency"); tv.setTextColor(Color.BLACK); tv.setTextSize(18); tv = (TextView) tr.findViewById(R.id.treatment_header_pills_to_take); tv.setText("To take"); tv.setTextColor(Color.BLACK); tv.setTextSize(18); tv = (TextView) tr.findViewById(R.id.treatment_header_active); tv.setText("Active"); tv.setTextColor(Color.BLACK); tv.setTextSize(18); tr.setBackgroundColor(Color.WHITE); table.addView(tr); }
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; } }
@Override public void onCreate(Context ctx) { LinearLayout linearLayout = new LinearLayout(ctx); linearLayout.setOrientation(LinearLayout.VERTICAL); // beds Spinner spinnerTextField = new Spinner(ctx); ArrayAdapter<Integer> aa = new ArrayAdapter<Integer>( ctx, android.R.layout.simple_spinner_item, new Integer[] {1, 2, 3}); aa.setDropDownViewResource(android.R.layout.select_dialog_singlechoice); spinnerTextField.setAdapter(aa); spinnerTextField.setOnItemSelectedListener(bedCountSpinnerItemSelectionListener); // options TableLayout amenitiesLayout = new TableLayout(ctx); amenitiesLayout.setColumnStretchable(0, false); amenitiesLayout.setColumnShrinkable(1, true); Amenity[] ams = Amenity.values(); for (Amenity amenity : ams) { TableRow tableRow = buildAmenityTableRow(ctx, amenity); amenitiesLayout.addView(tableRow); } linearLayout.addView( Utils.buildLabelAndField(ctx, ctx.getString(R.string.beds_label), spinnerTextField)); linearLayout.addView( Utils.buildLabelAndField(ctx, ctx.getString(R.string.amenities_label), amenitiesLayout)); addView(linearLayout); }
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 void addTableRow(TableLayout table, String parameter, String value) { TableRow row = new TableRow(table.getContext()); TableRow.LayoutParams trParams = new TableRow.LayoutParams(); trParams.setMargins(2, 2, 2, 1); row.setLayoutParams(trParams); row.setBackgroundColor(Color.rgb(0x00, 0x00, 0x00)); TextView text1 = new TextView(row.getContext()); text1.setTextSize(18); text1.setText(parameter); text1.setBackgroundColor(Color.rgb(0x18, 0x18, 0x18)); text1.setLayoutParams(trParams); text1.setPadding(5, 0, 0, 0); row.addView(text1); TextView text2 = new TextView(row.getContext()); text2.setTextSize(18); text2.setText(value); text2.setBackgroundColor(Color.rgb(0x18, 0x18, 0x18)); text2.setLayoutParams(trParams); text2.setPadding(5, 0, 0, 0); row.addView(text2); table.addView(row); }
void populateMatchesTable(ArrayList<Match> matches) { TableLayout tl = ((TableLayout) findViewById(R.id.upcomingMatches)); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); findViewById(R.id.loadingRow).setVisibility(View.GONE); for (final Match m : matches) { TableRow tr = (TableRow) inflater.inflate(R.layout.match_row, null); if (m.r1.equals(Constants.teamNumber) || m.r2.equals(Constants.teamNumber) || m.r3.equals(Constants.teamNumber) || m.b1.equals(Constants.teamNumber) || m.b2.equals(Constants.teamNumber) || m.b3.equals(Constants.teamNumber)) { tr.setBackgroundColor(Color.parseColor("#e3e3e3")); } ((TextView) tr.findViewById(R.id.r0)).setText(m.r1); ((TextView) tr.findViewById(R.id.r1)).setText(m.r2); ((TextView) tr.findViewById(R.id.r2)).setText(m.r3); ((TextView) tr.findViewById(R.id.b0)).setText(m.b1); ((TextView) tr.findViewById(R.id.b1)).setText(m.b2); ((TextView) tr.findViewById(R.id.b2)).setText(m.b3); ((TextView) tr.findViewById(R.id.redScore)).setText(m.redScore); ((TextView) tr.findViewById(R.id.blueScore)).setText(m.blueScore); ((TextView) tr.findViewById(R.id.matchDisplay)).setText(m.matchNumber); tl.addView(tr); } }
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()); } }
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 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 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); }
private void alertUser() { View view1 = ((Activity) context).getLayoutInflater().inflate(R.layout.popup_layout, null); TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea); TextView content = new TextView(view1.getContext()); content.setText(R.string.cancelUploading); content.setTextSize(20f); contentArea.addView(content); setTextView(view1, R.id.title, context.getResources().getString(R.string.alert)); AlertDialog dialog = new AlertDialog.Builder(context) .setView(view1) .setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { cancel(true); } }) .setNegativeButton( R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { progressDialog.show(); } }) .create(); dialog.show(); }
@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); } }
/** * -=========================================/ 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); } } }
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 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(); }
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 public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ScrollView sv = new ScrollView(getActivity()); TableLayout tl = new TableLayout(getActivity()); sv.addView(tl); if (displayReportController == null) { return sv; } AdsenseReportsGenerateResponse response = displayReportController.getReportResponse(); TableLayout.LayoutParams tableRowParams = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); tableRowParams.setMargins(10, 10, 10, 10); TableRow.LayoutParams tvParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); tvParams.setMargins(10, 10, 10, 10); List<Headers> headers = response.getHeaders(); TableRow tr = new TableRow(getActivity()); tl.addView(tr); for (Headers header : headers) { TextView tv = new TextView(getActivity()); tv.setText(header.getName()); tr.setLayoutParams(tableRowParams); tr.addView(tv); } if (response.getRows() != null && !response.getRows().isEmpty()) { for (List<String> row : response.getRows()) { TableRow trow = new TableRow(getActivity()); tl.addView(trow); for (String cell : row) { TextView tv = new TextView(getActivity()); tv.setText(cell); trow.addView(tv); tv.setLayoutParams(tvParams); tv.setPadding(15, 5, 15, 5); tv.setBackgroundColor(Color.WHITE); } } } return sv; }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); ScrollView sv = new ScrollView(this.getActivity().getApplicationContext()); TableLayout tableLayout = new TableLayout(this.getActivity().getApplicationContext()); sv.addView(tableLayout); TableRow tableRow; TextView textView; File dir = new File(Environment.getExternalStorageDirectory() + "/PhotoAR/"); File[] filelist = dir.listFiles(); // f.getName() // { // do your stuff here } if (filelist != null) { for (File f : filelist) { tableRow = new TableRow(this.getActivity().getApplicationContext()); textView = new TextView(this.getActivity().getApplicationContext()); Calendar cal = Calendar.getInstance(Locale.ENGLISH); cal.setTimeInMillis(Long.valueOf(f.getName().replace(".jpg", ""))); String date = DateFormat.format("dd-MM-yyyy hh:mm:ss", cal).toString(); ExifInterface exif = null; String message = ""; try { exif = new ExifInterface(f.getCanonicalPath()); message = exif.getAttribute("UserComment"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } textView.setText(date + " " + message); textView.setPadding(20, 20, 20, 20); tableRow.addView(textView); tableLayout.addView(tableRow); } } else { tableRow = new TableRow(this.getActivity().getApplicationContext()); textView = new TextView(this.getActivity().getApplicationContext()); textView.setText("[No Submissions]"); textView.setPadding(20, 20, 20, 20); tableRow.addView(textView); tableLayout.addView(tableRow); } // setContentView(tableLayout); View rootView = sv; // View rootView = inflater.inflate(R.layout.coming_soon_layout, container, false); return rootView; }
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); }