Java Code Examples for android.widget.CheckBox#setTextColor()
The following examples show how to use
android.widget.CheckBox#setTextColor() .
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: EmailAutoCompleteLayout.java From EmailAutoCompleteTextView with Apache License 2.0 | 6 votes |
public EmailAutoCompleteLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // Can't call through to super(Context, AttributeSet, int) since it doesn't exist on API 10 super(context, attrs); backgroundPermissionManager = new BackgroundPermissionManager(this, context); setOrientation(LinearLayout.VERTICAL); setAddStatesFromChildren(true); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EmailAutoCompleteLayout, defStyleAttr, defStyleRes); CharSequence permissionText = a.getText(R.styleable.EmailAutoCompleteLayout_permissionText); if (permissionText == null) { permissionText = context.getString(R.string.message_get_accounts_permission); } a.recycle(); permissionPrimer = new CheckBox(context); permissionPrimer.setTextColor(0x8a000000); permissionPrimer.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); permissionPrimer.setText(permissionText); addView(permissionPrimer); }
Example 2
Source File: HeatmapsPlacesDemoActivity.java From android-maps-utils with Apache License 2.0 | 6 votes |
/** * Creates check box for a given search term * * @param keyword the search terms associated with the check box */ private void makeCheckBox(final String keyword) { mCheckboxLayout.setVisibility(View.VISIBLE); // Make new checkbox CheckBox checkBox = new CheckBox(this); checkBox.setText(keyword); checkBox.setTextColor(HEATMAP_COLORS[mOverlaysRendered]); checkBox.setChecked(true); checkBox.setOnClickListener(view -> { CheckBox c = (CheckBox) view; // Text is the keyword TileOverlay overlay = mOverlays.get(keyword); if (overlay != null) { overlay.setVisible(c.isChecked()); } }); mCheckboxLayout.addView(checkBox); }
Example 3
Source File: TestCaseAdapter.java From azure-notificationhubs-android with Apache License 2.0 | 5 votes |
/** * Returns the view for a specific item on the list */ @Override public View getView(final int position, View convertView, ViewGroup parent) { View row = convertView; final TestCase testCase = getItem(position); if (row == null) { LayoutInflater inflater = ((Activity) mContext).getLayoutInflater(); row = inflater.inflate(mLayoutResourceId, parent, false); } final CheckBox checkBox = (CheckBox) row.findViewById(R.id.checkTestCase); String text = String.format("%s - %s", testCase.getName(), testCase.getStatus().toString()); if (testCase.getStatus() == TestStatus.Failed) { checkBox.setTextColor(Color.RED); } else if (testCase.getStatus() == TestStatus.Passed) { checkBox.setTextColor(Color.GREEN); } else { checkBox.setTextColor(Color.BLACK); } checkBox.setText(text); checkBox.setChecked(testCase.isEnabled()); checkBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { testCase.setEnabled(checkBox.isChecked()); } }); return row; }
Example 4
Source File: Agents.java From EmpireMobile with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void refreshAgents(){ try{ http2 = "https://".concat(address).concat("/api/agents?token=").concat(token); String method = "GET"; String results = new helper.getData().execute(http2, method).get(); //Create ArrayList for storing String names final List<String> allNames = new ArrayList<String>(); JSONObject jObj = new JSONObject(results); JSONArray getValues = jObj.getJSONArray("agents"); //loop over jsonArray, creating a jsonObject, then grabbing every value for the key "name" //and placing into the ArrayList for (int i = 0; i < getValues.length(); i++) { jObj = getValues.getJSONObject(i); String Id = jObj.getString("name"); allNames.add(Id); } //loop through ArrayList and draw a checkbox for every "name" value for (int i = 0; i < allNames.size(); i++) { cb = new CheckBox(MyApplication.getContext()); cb.setText(allNames.get(i)); cb.setTextColor(Color.WHITE); cb.setId(i); cb.setOnClickListener(MyListener); //Create Params for the checkboxes that go in a linear layout LinearLayout.LayoutParams checkParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); checkParams.setMargins(10, 10, 10, 10); checkParams.gravity = Gravity.START; agentScroll.addView(cb, checkParams); } }catch (Exception e){ e.printStackTrace(); } }
Example 5
Source File: AgentsNormal.java From EmpireMobile with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void refreshAgents(){ try{ http2 = "https://".concat(address).concat("/api/agents?token=").concat(token); String method = "GET"; String results = new helper.getData().execute(http2, method).get(); //Create ArrayList for storing String names final List<String> allNames = new ArrayList<String>(); JSONObject jObj = new JSONObject(results); JSONArray getValues = jObj.getJSONArray("agents"); //loop over jsonArray, creating a jsonObject, then grabbing every value for the key "name" //and placing into the ArrayList for (int i = 0; i < getValues.length(); i++) { jObj = getValues.getJSONObject(i); String Id = jObj.getString("name"); allNames.add(Id); } //loop through ArrayList and draw a checkbox for every "name" value for (int i = 0; i < allNames.size(); i++) { cb = new CheckBox(MyApplication.getContext()); cb.setText(allNames.get(i)); cb.setTextColor(Color.WHITE); cb.setId(i); cb.setOnClickListener(MyListener); //Create Params for the checkboxes that go in a linear layout LinearLayout.LayoutParams checkParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); checkParams.setMargins(10, 10, 10, 10); checkParams.gravity = Gravity.START; agentScroll.addView(cb, checkParams); } }catch (Exception e){ e.printStackTrace(); } }
Example 6
Source File: TestCaseAdapter.java From azure-mobile-apps-android-client with Apache License 2.0 | 5 votes |
/** * @return the view for a specific item on the list */ @Override public View getView(final int position, View convertView, ViewGroup parent) { View row = convertView; final TestCase testCase = getItem(position); if (row == null) { LayoutInflater inflater = ((Activity) mContext).getLayoutInflater(); row = inflater.inflate(mLayoutResourceId, parent, false); } final CheckBox checkBox = (CheckBox) row.findViewById(R.id.checkTestCase); String text = String.format("%s - %s", testCase.getName(), testCase.getStatus().toString()); if (testCase.getStatus() == TestStatus.Failed) { checkBox.setTextColor(Color.RED); } else if (testCase.getStatus() == TestStatus.Passed) { checkBox.setTextColor(Color.GREEN); } else if (testCase.getStatus() == TestStatus.MissingFeatures) { checkBox.setTextColor(Color.YELLOW); } else { checkBox.setTextColor(Color.BLACK); } checkBox.setText(text); checkBox.setChecked(testCase.isEnabled()); checkBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { testCase.setEnabled(checkBox.isChecked()); } }); return row; }
Example 7
Source File: TestCaseAdapter.java From Outlook-SDK-Android with MIT License | 5 votes |
/** * Returns the view for a specific item on the list */ @Override public View getView(final int position, View convertView, ViewGroup parent) { View row = convertView; final TestCase testCase = getItem(position); if (row == null) { LayoutInflater inflater = ((Activity) mContext).getLayoutInflater(); row = inflater.inflate(mLayoutResourceId, parent, false); } final CheckBox checkBox = (CheckBox) row.findViewById(R.id.checkTestCase); String text = String.format("%s - %s", testCase.getName(), testCase.getStatus().toString()); if (testCase.getStatus() == TestStatus.Failed) { checkBox.setTextColor(Color.RED); } else if (testCase.getStatus() == TestStatus.Passed) { checkBox.setTextColor(Color.GREEN); } else if (testCase.getStatus() == TestStatus.Disabled || testCase.getStatus() == TestStatus.NotSupported) { checkBox.setTextColor(Color.GRAY); } else { checkBox.setTextColor(Color.BLACK); } checkBox.setText(text); checkBox.setChecked(testCase.isSelected()); checkBox.setEnabled(testCase.isEnabled()); checkBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { testCase.setSelected(checkBox.isChecked()); } }); return row; }
Example 8
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 9
Source File: ThemeHelper.java From Liz with GNU General Public License v3.0 | 4 votes |
public void themeCheckBox(CheckBox chk) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { chk.setButtonTintList(getTintList()); chk.setTextColor(getTextColor()); } }
Example 10
Source File: ThemeHelper.java From Android-AudioRecorder-App with Apache License 2.0 | 4 votes |
public void themeCheckBox(CheckBox chk) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { chk.setButtonTintList(getTintList()); chk.setTextColor(getTextColor()); } }
Example 11
Source File: TestLogAdapter.java From Outlook-SDK-Android with MIT License | 4 votes |
/** * Returns the view for a specific item on the list */ @Override public View getView(final int position, View convertView, ViewGroup parent) { View row = convertView; final TestLog testResult = getItem(position); if (row == null) { LayoutInflater inflater = ((Activity) mContext).getLayoutInflater(); row = inflater.inflate(mLayoutResourceId, parent, false); } final CheckBox checkBox = (CheckBox) row.findViewById(R.id.checkTestLog); String text = String.format("%s - %s", testResult.getName(), testResult.getTestStatus().toString()); if (testResult.getTestStatus() == TestStatus.Failed) { checkBox.setTextColor(Color.RED); } else if (testResult.getTestStatus() == TestStatus.Passed) { checkBox.setTextColor(Color.GREEN); } else { checkBox.setTextColor(Color.GRAY); } checkBox.setText(text); /* checkBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { testResult.getTestCase().setSelected(checkBox.isChecked()); } }); */ final TextView textView = (TextView) row.findViewById(R.id.textLog); String errorMessage = testResult.getException() == null ? " - " : testResult.getException().getLocalizedMessage(); textView.setText(errorMessage); return row; }
Example 12
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 13
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); } }
Example 14
Source File: AddAccountActivity.java From YiBo with Apache License 2.0 | 4 votes |
private void initComponents() { LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase); ScrollView svContentPanel = (ScrollView)findViewById(R.id.svContentPanel); spServiceProvider = (Spinner) findViewById(R.id.spServiceProvider); spConfigApp = (Spinner) findViewById(R.id.spConfigApp); etUsername = (EditText) findViewById(R.id.etUsername); etPassword = (EditText) findViewById(R.id.etPassword); cbMakeDefault = (CheckBox) findViewById(R.id.cbDefault); cbFollowOffical = (CheckBox) findViewById(R.id.cbFollowOffical); cbUseProxy = (CheckBox) findViewById(R.id.cbUseApiProxy); etRestProxy = (EditText) findViewById(R.id.etRestProxy); etSearchProxy = (EditText) findViewById(R.id.etSearchProxy); btnAuthorize = (Button) findViewById(R.id.btnAuthorize); LinearLayout llOAuthIntro = (LinearLayout)findViewById(R.id.llOAuthIntro); TextView tvOAuthIntro = (TextView)findViewById(R.id.tvOAuthIntro); LinearLayout llFooterAction = (LinearLayout)findViewById(R.id.llFooterAction); ThemeUtil.setSecondaryHeader(llHeaderBase); ThemeUtil.setContentBackground(svContentPanel); spServiceProvider.setBackgroundDrawable(theme.getDrawable("selector_btn_dropdown")); spConfigApp.setBackgroundDrawable(theme.getDrawable("selector_btn_dropdown")); int padding2 = theme.dip2px(2); spServiceProvider.setPadding(padding2, padding2, padding2, padding2); spConfigApp.setPadding(padding2, padding2, padding2, padding2); int content = theme.getColor("content"); etUsername.setBackgroundDrawable(theme.getDrawable("selector_input_frame")); etUsername.setTextColor(content); etPassword.setBackgroundDrawable(theme.getDrawable("selector_input_frame")); etPassword.setTextColor(content); cbMakeDefault.setButtonDrawable(theme.getDrawable("selector_checkbox")); cbMakeDefault.setTextColor(content); cbFollowOffical.setButtonDrawable(theme.getDrawable("selector_checkbox")); cbFollowOffical.setTextColor(content); cbUseProxy.setButtonDrawable(theme.getDrawable("selector_checkbox")); cbUseProxy.setTextColor(content); etRestProxy.setBackgroundDrawable(theme.getDrawable("selector_input_frame")); etRestProxy.setTextColor(content); etSearchProxy.setBackgroundDrawable(theme.getDrawable("selector_input_frame")); etSearchProxy.setTextColor(content); llOAuthIntro.setBackgroundDrawable(theme.getDrawable("bg_frame_normal")); int padding8 = theme.dip2px(8); llOAuthIntro.setPadding(padding8, padding8, padding8, padding8); tvOAuthIntro.setTextColor(theme.getColor("quote")); llFooterAction.setBackgroundDrawable(theme.getDrawable("bg_footer_action")); llFooterAction.setPadding(padding8, padding8, padding8, padding8); llFooterAction.setGravity(Gravity.CENTER); ThemeUtil.setBtnActionPositive(btnAuthorize); TextView tvTitle = (TextView) this.findViewById(R.id.tvTitle); tvTitle.setText(R.string.title_add_account); ConfigSystemDao configDao = new ConfigSystemDao(this); Passport passport = configDao.getPassport(); if (passport != null) { isCustomKeyLevel = passport.getPointsLevel().getPoints() >= Constants.POINTS_CUSTOM_SOURCE_LEVEL ; } isCustomKeyLevel = true; // 调试用 if (isCustomKeyLevel) { } }
Example 15
Source File: EditRetweetActivity.java From YiBo with Apache License 2.0 | 4 votes |
private void initComponents() { LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase); LinearLayout llContentPanel = (LinearLayout)findViewById(R.id.llContentPanel); LinearLayout llEditText = (LinearLayout)findViewById(R.id.llEditText); MultiAutoCompleteTextView etText = (MultiAutoCompleteTextView)findViewById(R.id.etText); Button btnEmotion = (Button)this.findViewById(R.id.btnEmotion); Button btnMention = (Button)this.findViewById(R.id.btnMention); Button btnTopic = (Button)this.findViewById(R.id.btnTopic); Button btnTextCount = (Button)this.findViewById(R.id.btnTextCount); cbComment = (CheckBox) this.findViewById(R.id.cbComment); cbCommentToOrigin = (CheckBox)this.findViewById(R.id.cbCommentToOrigin); tvText = (TextView)this.findViewById(R.id.tvText); ThemeUtil.setSecondaryHeader(llHeaderBase); ThemeUtil.setContentBackground(llContentPanel); int padding6 = theme.dip2px(6); int padding8 = theme.dip2px(8); llContentPanel.setPadding(padding6, padding8, padding6, 0); llEditText.setBackgroundDrawable(theme.getDrawable("bg_input_frame_normal")); etText.setTextColor(theme.getColor("content")); btnEmotion.setBackgroundDrawable(theme.getDrawable("selector_btn_emotion")); btnMention.setBackgroundDrawable(theme.getDrawable("selector_btn_mention")); btnTopic.setBackgroundDrawable(theme.getDrawable("selector_btn_topic")); btnTextCount.setBackgroundDrawable(theme.getDrawable("selector_btn_text_count")); btnTextCount.setPadding(padding6, 0, theme.dip2px(20), 0); btnTextCount.setTextColor(theme.getColor("status_capability")); cbComment.setButtonDrawable(theme.getDrawable("selector_checkbox")); cbComment.setTextColor(theme.getColor("content")); cbCommentToOrigin.setButtonDrawable(theme.getDrawable("selector_checkbox")); cbCommentToOrigin.setTextColor(theme.getColor("content")); tvText.setTextColor(theme.getColor("quote")); TextView tvTitle = (TextView)this.findViewById(R.id.tvTitle); tvTitle.setText(R.string.title_retweet); MicroBlogTextWatcher textWatcher = new MicroBlogTextWatcher(this); etText.addTextChangedListener(textWatcher); etText.setHint(R.string.hint_retweet); etText.requestFocus(); etText.setAdapter(new UserSuggestAdapter(this)); etText.setTokenizer(new EditMicroBlogTokenizer()); retweetedStatus = status; if (status.getServiceProvider() != ServiceProvider.Sohu) { if (status.getServiceProvider() == ServiceProvider.Fanfou || status.getRetweetedStatus() != null) { etText.setText( String.format( FeaturePatternUtils.getRetweetFormat(status.getServiceProvider()), FeaturePatternUtils.getRetweetSeparator(status.getServiceProvider()), status.getUser().getMentionName(), status.getText() ) ); } if (!(status.getServiceProvider() == ServiceProvider.Fanfou || status.getRetweetedStatus() == null)) { retweetedStatus = status.getRetweetedStatus(); } etText.setSelection(0); } int length = StringUtil.getLengthByByte(etText.getText().toString()); int leavings = (int) Math.floor((double) (Constants.STATUS_TEXT_MAX_LENGTH * 2 - length) / 2); btnTextCount.setText((leavings < 0 ? "-" : "") + Math.abs(leavings)); String lableComment = this.getString(R.string.label_retweet_with_comment, status.getUser().getScreenName()); cbComment.setText(lableComment); if (isComment2OriginVisible()) { String lableCommentToOrigin = this.getString( R.string.label_retweet_with_comment_to_origin, retweetedStatus.getUser().getScreenName()); cbCommentToOrigin.setText(lableCommentToOrigin); cbCommentToOrigin.setVisibility(View.VISIBLE); } String promptText = retweetedStatus.getUser().getMentionTitleName() + ":" + retweetedStatus.getText(); tvText.setText(promptText); }