for(int i=0;i<totalCB;i++){ CheckBox chB=new CheckBox(context); ... chB.setId(i); layout.add(...);// add checkbox to view }
public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub LayoutInflater in = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = in.inflate(R.layout.inflator, null); CheckBox c = (CheckBox) convertView.findViewById(R.id.checkBox); c.setId(position); return convertView;
final TableRow tbRowGremio = new TableRow(contexto); tbRowGremio.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)); tbRowGremio.setId((numeroFila)); LayoutInflater inflater = (LayoutInflater) contexto.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View lineaAPintar = inflater.inflate(R.layout.filalistagremios, null); lineaAPintar.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); final CheckBox cbGremioActivo = (CheckBox) lineaAPintar.findViewById(R.id.cbGremioActivo); cbGremioActivo.setId(numeroFila); TextView tvGremio = (TextView) lineaAPintar.findViewById(R.id.tvGremio); tvGremio.setText(gremioQueQuiereAnadir); TextView tvComentario = (TextView) lineaAPintar.findViewById(R.id.tvComentario); tvComentario.setText(etComentario.getText().toString()); tbRowGremio.addView(lineaAPintar); tablaGremios.addView(tbRowGremio);
CheckBox tvchkall = new CheckBox(ItemCodeRelease.this); tvchkall.setId(101); tvchkall.setOnClickListener(getOnClickDoSomething(tvchkall));
final HashMap<Integer,Integer> myList=new HashMap<Integer, Integer>(); for(int i=1;i<=20;i++) { final CheckBox cb=new CheckBox(context); cb.setId(i); myList.put(i, 0); final int pos=i; cb.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean arg1) { if(cb.isChecked()) myList.put(pos, 1);// checkbox checked else myList.put(pos,0);//checkbox unchecked } }); }
RelativeLayout rl=new RelativeLayout(CreateFuelOnlyInspectionActivity.this); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); int rlMarginTop_px = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics()); lp.topMargin=rlMarginTop_px; rl.setLayoutParams(lp); CheckBox cb1; RelativeLayout.LayoutParams cbParams1=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); for(int i=0;i<=6; i++){ cb1=new CheckBox(CreateFuelOnlyInspectionActivity.this); cb1.setId(i); cb1.setTag(""+i); cb1.setLayoutParams(cbParams1); cb1.setButtonDrawable(getResources().getDrawable(R.drawable.checkbox_selector)); rl.addView(cb1); } // enable view page here
mUserProfile = mNavigationCallback.getUserProfile(); List<Contact> contacts = mUserProfile.getContacts(); for (Contact c : contacts) { View view = View.inflate(getActivity(), R.layout.item_contact, null); TextView tv = (TextView) view.findViewById(R.id.tvPhone); tv.setText(c.getValue()); CheckBox cb = (CheckBox) view.findViewById(R.id.cbContactChecked); cb.setChecked(c.isSelected) cb.setId(generateViewId()); if (c.getType().equals("email")) { llEmailContacts.addView(view); } if (c.getType().equals("phone")) { llPhoneContacts.addView(view); } }
public void onCreate(Bundle state) { //Get your userProfile from state. If it is null, there was no state saved then get it like you //already do = mUserProfile = mNavigationCallback.getUserProfile(); List<Contact> contacts = mUserProfile.getContacts(); for (Contact c : contacts) { View view = View.inflate(getActivity(), R.layout.item_contact, null); TextView tv = (TextView) view.findViewById(R.id.tvPhone); tv.setText(c.getValue()); CheckBox cb = (CheckBox) view.findViewById(R.id.cbContactChecked); cb.setChecked(c.isSelected) cb.setId(generateViewId()); if (c.getType().equals("email")) { llEmailContacts.addView(view); } if (c.getType().equals("phone")) { llPhoneContacts.addView(view); } } }
private CheckBox createTargetVisibleField() { final CheckBox checkBox = new CheckBox(); checkBox.setId(UIComponentIdProvider.METADATA_TARGET_VISIBLE_ID); checkBox.setCaption(i18n.getMessage("metadata.targetvisible")); checkBox.addValueChangeListener(this::onCheckBoxChange); return checkBox; }
private CheckBox createTargetVisibleField() { final CheckBox checkBox = new CheckBox(); checkBox.setId(UIComponentIdProvider.METADATA_TARGET_VISIBLE_ID); checkBox.setCaption(i18n.getMessage("metadata.targetvisible")); checkBox.addValueChangeListener(this::onCheckBoxChange); return checkBox; }
mUserProfile = mNavigationCallback.getUserProfile(); List<Contact> contacts = mUserProfile.getContacts(); for (Contact c : contacts) { View view = View.inflate(getActivity(), R.layout.item_contact, null); TextView tv = (TextView) view.findViewById(R.id.tvPhone); tv.setText(c.getValue()); CheckBox cb = (CheckBox) view.findViewById(R.id.cbContactChecked); if (c.getViewId() == 0) { c.setViewId(generateViewId()); } cb.setId(c.getViewId()); cb.setTag(c); Timber.d("setting CB: " + "ID :" + cb.getId() + " tag " + cb.getTag()); cb.setOnCheckedChangeListener(mOnCheckedChangeListener); if (c.getType().equals("email")) { llEmailContacts.addView(view); } if (c.getType().equals("phone")) { llPhoneContacts.addView(view); } }
private VerticalLayout initView() { final Label label = new Label(i18n.getMessage("label.auto.assign.description")); checkBox = new CheckBox(i18n.getMessage("label.auto.assign.enable")); checkBox.setId(UIComponentIdProvider.DIST_SET_SELECT_ENABLE_ID); checkBox.setImmediate(true); checkBox.addValueChangeListener(this); setTableEnabled(false); final VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.addComponent(label); verticalLayout.addComponent(checkBox); verticalLayout.addComponent(dsTable); return verticalLayout; }
private VerticalLayout initView() { final Label label = new Label(i18n.getMessage("label.auto.assign.description")); checkBox = new CheckBox(i18n.getMessage("label.auto.assign.enable")); checkBox.setId(UIComponentIdProvider.DIST_SET_SELECT_ENABLE_ID); checkBox.setImmediate(true); checkBox.addValueChangeListener(this); setTableEnabled(false); final VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.addComponent(label); verticalLayout.addComponent(checkBox); verticalLayout.addComponent(dsTable); return verticalLayout; }
private CheckBox enableMaintenanceWindowControl() { final CheckBox enableMaintenanceWindow = new CheckBox( getI18n().getMessage("caption.maintenancewindow.enabled")); enableMaintenanceWindow.setId(UIComponentIdProvider.MAINTENANCE_WINDOW_ENABLED_ID); enableMaintenanceWindow.addStyleName(ValoTheme.CHECKBOX_SMALL); enableMaintenanceWindow.addStyleName("dist-window-maintenance-window-enable"); enableMaintenanceWindow.addValueChangeListener(event -> { final Boolean isMaintenanceWindowEnabled = enableMaintenanceWindow.getValue(); maintenanceWindowLayout.setVisible(isMaintenanceWindowEnabled); maintenanceWindowLayout.setEnabled(isMaintenanceWindowEnabled); enableSaveButton(!isMaintenanceWindowEnabled); maintenanceWindowLayout.clearAllControls(); }); return enableMaintenanceWindow; }
private CheckBox enableMaintenanceWindowControl() { final CheckBox enableMaintenanceWindow = new CheckBox( getI18n().getMessage("caption.maintenancewindow.enabled")); enableMaintenanceWindow.setId(UIComponentIdProvider.MAINTENANCE_WINDOW_ENABLED_ID); enableMaintenanceWindow.addStyleName(ValoTheme.CHECKBOX_SMALL); enableMaintenanceWindow.addStyleName("dist-window-maintenance-window-enable"); enableMaintenanceWindow.addValueChangeListener(event -> { final Boolean isMaintenanceWindowEnabled = enableMaintenanceWindow.getValue(); maintenanceWindowLayout.setVisible(isMaintenanceWindowEnabled); maintenanceWindowLayout.setEnabled(isMaintenanceWindowEnabled); enableSaveButton(!isMaintenanceWindowEnabled); maintenanceWindowLayout.clearAllControls(); }); return enableMaintenanceWindow; }
private CheckBox enableMaintenanceWindowControl() { final CheckBox enableMaintenanceWindow = new CheckBox( getI18n().getMessage("caption.maintenancewindow.enabled")); enableMaintenanceWindow.setId(UIComponentIdProvider.MAINTENANCE_WINDOW_ENABLED_ID); enableMaintenanceWindow.addStyleName(ValoTheme.CHECKBOX_SMALL); enableMaintenanceWindow.addStyleName("dist-window-maintenance-window-enable"); enableMaintenanceWindow.addValueChangeListener(event -> { final Boolean isMaintenanceWindowEnabled = enableMaintenanceWindow.getValue(); maintenanceWindowLayout.setVisible(isMaintenanceWindowEnabled); maintenanceWindowLayout.setEnabled(isMaintenanceWindowEnabled); enableSaveButton(!isMaintenanceWindowEnabled); maintenanceWindowLayout.clearAllControls(); }); return enableMaintenanceWindow; }
private CheckBox enableMaintenanceWindowControl() { final CheckBox enableMaintenanceWindow = new CheckBox( getI18n().getMessage("caption.maintenancewindow.enabled")); enableMaintenanceWindow.setId(UIComponentIdProvider.MAINTENANCE_WINDOW_ENABLED_ID); enableMaintenanceWindow.addStyleName(ValoTheme.CHECKBOX_SMALL); enableMaintenanceWindow.addStyleName("dist-window-maintenance-window-enable"); enableMaintenanceWindow.addValueChangeListener(event -> { final Boolean isMaintenanceWindowEnabled = enableMaintenanceWindow.getValue(); maintenanceWindowLayout.setVisible(isMaintenanceWindowEnabled); maintenanceWindowLayout.setEnabled(isMaintenanceWindowEnabled); enableSaveButton(!isMaintenanceWindowEnabled); maintenanceWindowLayout.clearAllControls(); }); return enableMaintenanceWindow; }
private DurationConfigField(final String id) { super(2, 2); this.addStyleName("duration-config-field"); this.setSpacing(true); this.setImmediate(true); this.setColumnExpandRatio(1, 1.0F); durationField.setId(id + ".field"); checkBox.setId(id + ".checkbox"); this.addComponent(checkBox, 0, 0); this.setComponentAlignment(checkBox, Alignment.MIDDLE_LEFT); this.addComponent(durationField, 1, 0); this.setComponentAlignment(durationField, Alignment.MIDDLE_LEFT); checkBox.addValueChangeListener(event -> checkBoxChange()); durationField.addValueChangeListener(event -> notifyConfigurationChanged()); }
private DurationConfigField(final String id) { super(2, 2); this.addStyleName("duration-config-field"); this.setSpacing(true); this.setImmediate(true); this.setColumnExpandRatio(1, 1.0F); durationField.setId(id + ".field"); checkBox.setId(id + ".checkbox"); this.addComponent(checkBox, 0, 0); this.setComponentAlignment(checkBox, Alignment.MIDDLE_LEFT); this.addComponent(durationField, 1, 0); this.setComponentAlignment(durationField, Alignment.MIDDLE_LEFT); checkBox.addValueChangeListener(event -> checkBoxChange()); durationField.addValueChangeListener(event -> notifyConfigurationChanged()); }
@SuppressWarnings("unchecked") private void addTargetTableForUpdate(final SoftwareModuleType swModuleType, final boolean mandatory) { if (getTwinTables().getSelectedTableContainer() == null) { return; } final Item saveTblitem = getTwinTables().getSelectedTableContainer().addItem(swModuleType.getId()); getTwinTables().getSourceTable().removeItem(swModuleType.getId()); saveTblitem.getItemProperty(DistributionSetTypeSoftwareModuleSelectLayout.getDistTypeName()) .setValue(swModuleType.getName()); final CheckBox mandatoryCheckbox = new CheckBox("", mandatory); mandatoryCheckbox.setId(swModuleType.getName()); saveTblitem.getItemProperty(DistributionSetTypeSoftwareModuleSelectLayout.getDistTypeMandatory()) .setValue(mandatoryCheckbox); final Item originalItem = originalSelectedTableContainer.addItem(swModuleType.getId()); originalItem.getItemProperty(DistributionSetTypeSoftwareModuleSelectLayout.getDistTypeName()) .setValue(swModuleType.getName()); originalItem.getItemProperty(DistributionSetTypeSoftwareModuleSelectLayout.getDistTypeMandatory()) .setValue(mandatoryCheckbox); getWindow().updateAllComponents(mandatoryCheckbox); }