Java Code Examples for android.widget.CheckBox#setTextSize()
The following examples show how to use
android.widget.CheckBox#setTextSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseCreate.java From indigenous-android with GNU General Public License v3.0 | 4 votes |
/** * Set the syndication targets. */ public void setSyndicationTargets() { LinearLayout syndicationLayout = findViewById(R.id.syndicationTargets); String syndicationTargetsString = user.getSyndicationTargets(); if (syndicationLayout != null && syndicationTargetsString.length() > 0) { syndicationLayout.removeAllViews(); JSONObject object; try { JSONArray itemList = new JSONArray(syndicationTargetsString); if (itemList.length() > 0) { TextView syn = new TextView(this); syn.setText(R.string.syndicate_to); syn.setPadding(20, 10, 0, 0); syn.setTextSize(15); syn.setTextColor(getResources().getColor(R.color.textColor)); syndicationLayout.addView(syn); syndicationLayout.setPadding(10, 0,0, 0 ); } for (int i = 0; i < itemList.length(); i++) { object = itemList.getJSONObject(i); Syndication syndication = new Syndication(); syndication.setUid(object.getString("uid")); syndication.setName(object.getString("name")); if (object.has("checked")) { syndication.setChecked(object.getBoolean("checked")); } syndicationTargets.add(syndication); CheckBox ch = new CheckBox(this); ch.setText(syndication.getName()); ch.setId(i); ch.setTextSize(15); ch.setPadding(0, 10, 0, 10); ch.setTextColor(getResources().getColor(R.color.textColor)); if (syndication.isChecked()) { ch.setChecked(true); } syndicationLayout.addView(ch); } } catch (JSONException e) { String message = String.format(getString(R.string.syndication_targets_parse_error), e.getMessage()); final Snackbar snack = Snackbar.make(layout, message, Snackbar.LENGTH_INDEFINITE); snack.setAction(getString(R.string.close), new View.OnClickListener() { @Override public void onClick(View v) { snack.dismiss(); } } ); snack.show(); } } }
Example 2
Source File: ProviderTable.java From ssj with GNU General Public License v3.0 | 4 votes |
/** * @param activity Activity * @param mainObject Object * @param dividerTop boolean * @return TableRow */ public static TableRow createStreamTable(Activity activity, final Object mainObject, boolean dividerTop, int heading) { TableRow tableRow = new TableRow(activity); tableRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT)); LinearLayout linearLayout = new LinearLayout(activity); linearLayout.setOrientation(LinearLayout.VERTICAL); if (dividerTop) { //add divider linearLayout.addView(Util.addDivider(activity)); } TextView textViewName = new TextView(activity); textViewName.setText(heading); textViewName.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); textViewName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); linearLayout.addView(textViewName); //get possible providers final Object[] objects = PipelineBuilder.getInstance().getPossibleStreamConnections(mainObject); // if (objects.length > 0) { for (int i = 0; i < objects.length; i++) { CheckBox checkBox = new CheckBox(activity); checkBox.setText(objects[i].getClass().getSimpleName()); checkBox.setTextSize(TypedValue.COMPLEX_UNIT_SP, 19); Object[] providers = PipelineBuilder.getInstance().getStreamConnections(mainObject); if (providers != null) { for (Object provider : providers) { if (objects[i].equals(provider)) { checkBox.setChecked(true); break; } } } final int count = i; checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { final Object o = objects[count]; @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { PipelineBuilder.getInstance().addStreamConnection(mainObject, (Provider) o); } else { PipelineBuilder.getInstance().removeStreamConnection(mainObject, (Provider) o); } } }); linearLayout.addView(checkBox); } } else { return null; } tableRow.addView(linearLayout); return tableRow; }
Example 3
Source File: ProviderTable.java From ssj with GNU General Public License v3.0 | 4 votes |
/** * @param activity Activity * @param mainObject Object * @param dividerTop boolean * @return TableRow */ public static TableRow createEventTable(Activity activity, final Object mainObject, boolean dividerTop) { TableRow tableRow = new TableRow(activity); tableRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT)); LinearLayout linearLayout = new LinearLayout(activity); linearLayout.setOrientation(LinearLayout.VERTICAL); if (dividerTop) { //add divider linearLayout.addView(Util.addDivider(activity)); } TextView textViewName = new TextView(activity); textViewName.setText(R.string.str_event_input); textViewName.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); textViewName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); linearLayout.addView(textViewName); //get possible providers final Object[] objects = PipelineBuilder.getInstance().getPossibleEventConnections(mainObject); // if (objects.length > 0) { for (int i = 0; i < objects.length; i++) { if(PipelineBuilder.getInstance().isManagedFeedback(objects[i])) continue; CheckBox checkBox = new CheckBox(activity); checkBox.setText(objects[i].getClass().getSimpleName()); checkBox.setTextSize(TypedValue.COMPLEX_UNIT_SP, 19); Object[] providers = PipelineBuilder.getInstance().getEventConnections(mainObject); if (providers != null) { for (Object provider : providers) { if (objects[i].equals(provider)) { checkBox.setChecked(true); break; } } } final int count = i; checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { final Object o = objects[count]; @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { PipelineBuilder.getInstance().addEventConnection(mainObject, (Component) o); } else { PipelineBuilder.getInstance().removeEventConnection(mainObject, (Component) o); } } }); linearLayout.addView(checkBox); } } else { return null; } tableRow.addView(linearLayout); return tableRow; }
Example 4
Source File: ProviderTable.java From ssj with GNU General Public License v3.0 | 4 votes |
/** * @param activity Activity * @param mainObject Object * @param dividerTop boolean * @return TableRow */ public static TableRow createModelTable(Activity activity, final Object mainObject, boolean dividerTop, int heading) { TableRow tableRow = new TableRow(activity); tableRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT)); LinearLayout linearLayout = new LinearLayout(activity); linearLayout.setOrientation(LinearLayout.VERTICAL); if (dividerTop) { //add divider linearLayout.addView(Util.addDivider(activity)); } TextView textViewName = new TextView(activity); textViewName.setText(heading); textViewName.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); textViewName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); linearLayout.addView(textViewName); //get possible providers final Object[] objects = (mainObject instanceof IModelHandler) ? PipelineBuilder.getInstance().getAll(PipelineBuilder.Type.Model) : PipelineBuilder.getInstance().getModelHandlers(); if (objects.length > 0) { for (int i = 0; i < objects.length; i++) { CheckBox checkBox = new CheckBox(activity); checkBox.setText(objects[i].getClass().getSimpleName()); checkBox.setTextSize(TypedValue.COMPLEX_UNIT_SP, 19); Object[] connections = PipelineBuilder.getInstance().getModelConnections(mainObject); if (connections != null) { for (Object conn : connections) { if (objects[i].equals(conn)) { checkBox.setChecked(true); break; } } } final int count = i; checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { final Object o = objects[count]; @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { PipelineBuilder.getInstance().addModelConnection((Component) mainObject, (Component) o); } else { PipelineBuilder.getInstance().removeModelConnection((Component) mainObject, (Component) o); } } }); linearLayout.addView(checkBox); } } else { return null; } tableRow.addView(linearLayout); return tableRow; }
Example 5
Source File: OBooleanField.java From hr with GNU Affero General Public License v3.0 | 4 votes |
public void initControl() { mReady = false; LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); removeAllViews(); setOrientation(VERTICAL); if (isEditable()) { if (mWidget != null) { switch (mWidget) { case Switch: mSwitch = new Switch(mContext); mSwitch.setLayoutParams(params); mSwitch.setOnCheckedChangeListener(this); setValue(getValue()); if (mLabel != null) mSwitch.setText(mLabel); if (textSize > -1) { mSwitch.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } if (appearance > -1) { mSwitch.setTextAppearance(mContext, appearance); } mSwitch.setTextColor(textColor); addView(mSwitch); break; default: break; } } else { mCheckbox = new CheckBox(mContext); mCheckbox.setLayoutParams(params); mCheckbox.setOnCheckedChangeListener(this); if (mLabel != null) mCheckbox.setText(mLabel); if (textSize > -1) { mCheckbox.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } if (appearance > -1) { mCheckbox.setTextAppearance(mContext, appearance); } mCheckbox.setTextColor(textColor); addView(mCheckbox); } } else { txvView = new TextView(mContext); txvView.setLayoutParams(params); txvView.setText(getCheckBoxLabel()); if (mLabel != null) txvView.setText(mLabel); if (textSize > -1) { txvView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } if (appearance > -1) { txvView.setTextAppearance(mContext, appearance); } addView(txvView); } }
Example 6
Source File: SelectMultiWidget.java From commcare-android with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public SelectMultiWidget(Context context, FormEntryPrompt prompt) { super(context, prompt); mCheckboxes = new Vector<>(); mItems = getSelectChoices(); setOrientation(LinearLayout.VERTICAL); Vector<Selection> ve = new Vector<>(); if (mPrompt.getAnswerValue() != null) { ve = (Vector<Selection>)getCurrentAnswer().getValue(); } //Is this safe enough from collisions? buttonIdBase = Math.abs(mPrompt.getIndex().hashCode()); if (mItems != null) { for (int i = 0; i < mItems.size(); i++) { // no checkbox group so id by answer + offset final CheckBox c = new CheckBox(getContext()); c.setId(buttonIdBase + i); String markdownText = prompt.getSelectItemMarkdownText(mItems.get(i)); if (markdownText != null) { c.setText(forceMarkdown(markdownText)); } else { c.setText(prompt.getSelectChoiceText(mItems.get(i))); } c.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontSize); c.setFocusable(!mPrompt.isReadOnly()); c.setEnabled(!mPrompt.isReadOnly()); int padding = (int)Math.floor(context.getResources().getDimension(R.dimen.select_padding)); c.setPadding(c.getPaddingLeft(), 0, padding, 0); for (int vi = 0; vi < ve.size(); vi++) { // match based on value, not key if (mItems.get(i).getValue().equals(ve.elementAt(vi).getValue())) { c.setChecked(true); break; } } //Note: This gets fired during setup as well, so this listener should only //be added after everything about the checkbox is set up // when clicked, check for readonly before toggling c.setOnCheckedChangeListener((buttonView, isChecked) -> { if (!mCheckboxInit && mPrompt.isReadOnly()) { if (buttonView.isChecked()) { buttonView.setChecked(false); } else { buttonView.setChecked(true); } } widgetEntryChanged(); }); mCheckboxes.add(c); String audioURI = mPrompt.getSpecialFormSelectChoiceText(mItems.get(i), FormEntryCaption.TEXT_FORM_AUDIO); String imageURI = mPrompt.getSpecialFormSelectChoiceText(mItems.get(i), FormEntryCaption.TEXT_FORM_IMAGE); String videoURI = mPrompt.getSpecialFormSelectChoiceText(mItems.get(i), "video"); String bigImageURI = mPrompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image"); MediaLayout mediaLayout = MediaLayout.buildAudioImageVisualLayout(getContext(), c, audioURI, imageURI, videoURI, bigImageURI); addView(mediaLayout); mediaLayout.setPadding(0, padding, 0, padding); mediaLayout.setOnClickListener(v -> c.performClick()); // Last, add the dividing line between elements (except for the last element) ImageView divider = new ImageView(getContext()); divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright); if (i != mItems.size() - 1) { addView(divider); } } } mCheckboxInit = false; }
Example 7
Source File: OBooleanField.java From framework with GNU Affero General Public License v3.0 | 4 votes |
public void initControl() { mReady = false; LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); removeAllViews(); setOrientation(VERTICAL); if (isEditable()) { if (mWidget != null) { switch (mWidget) { case Switch: mSwitch = new Switch(mContext); mSwitch.setLayoutParams(params); mSwitch.setOnCheckedChangeListener(this); setValue(getValue()); if (mLabel != null) mSwitch.setText(mLabel); if (textSize > -1) { mSwitch.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } if (appearance > -1) { mSwitch.setTextAppearance(mContext, appearance); } mSwitch.setTextColor(textColor); addView(mSwitch); break; default: break; } } else { mCheckbox = new CheckBox(mContext); mCheckbox.setLayoutParams(params); mCheckbox.setOnCheckedChangeListener(this); if (mLabel != null) mCheckbox.setText(mLabel); if (textSize > -1) { mCheckbox.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } if (appearance > -1) { mCheckbox.setTextAppearance(mContext, appearance); } mCheckbox.setTextColor(textColor); addView(mCheckbox); } } else { txvView = new TextView(mContext); txvView.setLayoutParams(params); txvView.setText(getCheckBoxLabel()); if (mLabel != null) txvView.setText(mLabel); if (textSize > -1) { txvView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } if (appearance > -1) { txvView.setTextAppearance(mContext, appearance); } addView(txvView); } }