Here are the examples of the java api class android.widget.CompoundButton taken from open source projects.
1. EditShareFragment#setPermissionsListening()
Project: MyRepository-master
File: EditShareFragment.java
File: EditShareFragment.java
/** * Binds or unbinds listener for user actions to enable or disable a permission on the edited share * to the views receiving the user events. * * @param editShareView Root view in the fragment. * @param enable When 'true', listener is bound to view; when 'false', it is unbound. */ private void setPermissionsListening(View editShareView, boolean enable) { if (enable && mOnPrivilegeChangeListener == null) { mOnPrivilegeChangeListener = new OnPrivilegeChangeListener(); } CompoundButton.OnCheckedChangeListener changeListener = enable ? mOnPrivilegeChangeListener : null; CompoundButton compound; compound = (CompoundButton) editShareView.findViewById(R.id.canShareSwitch); compound.setOnCheckedChangeListener(changeListener); compound = (CompoundButton) editShareView.findViewById(R.id.canEditSwitch); compound.setOnCheckedChangeListener(changeListener); if (mFile.isFolder()) { compound = (CompoundButton) editShareView.findViewById(R.id.canEditCreateCheckBox); compound.setOnCheckedChangeListener(changeListener); compound = (CompoundButton) editShareView.findViewById(R.id.canEditChangeCheckBox); compound.setOnCheckedChangeListener(changeListener); compound = (CompoundButton) editShareView.findViewById(R.id.canEditDeleteCheckBox); compound.setOnCheckedChangeListener(changeListener); } }
2. AudioEffectSettingsBaseFragment#onUpdateActionBarAndOptionsMenu()
Project: android-openslmediaplayer
File: AudioEffectSettingsBaseFragment.java
File: AudioEffectSettingsBaseFragment.java
@Override protected void onUpdateActionBarAndOptionsMenu(Menu menu, MenuInflater inflater) { super.onUpdateActionBarAndOptionsMenu(menu, inflater); // inflate menu for audio effect settings inflater.inflate(R.menu.audio_effect_settings, menu); // set up effect On/Off switch MenuItem menuSwitchItem = menu.findItem(R.id.menu_item_action_bar_switch); CompoundButton effectOnOffSwitch = (CompoundButton) MenuItemCompat.getActionView(menuSwitchItem); effectOnOffSwitch.setChecked(onGetActionBarSwitchCheckedState()); effectOnOffSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { onActionBarSwitchCheckedChanged(buttonView, isChecked); } }); ActionBar actionBar = getActionBar(); actionBar.setTitle(onGetActionBarTitleText()); }
3. EditShareFragment#setPermissionsListening()
Project: android
File: EditShareFragment.java
File: EditShareFragment.java
/** * Binds or unbinds listener for user actions to enable or disable a permission on the edited share * to the views receiving the user events. * * @param editShareView Root view in the fragment. * @param enable When 'true', listener is bound to view; when 'false', it is unbound. */ private void setPermissionsListening(View editShareView, boolean enable) { if (enable && mOnPrivilegeChangeListener == null) { mOnPrivilegeChangeListener = new OnPrivilegeChangeListener(); } CompoundButton.OnCheckedChangeListener changeListener = enable ? mOnPrivilegeChangeListener : null; CompoundButton compound; compound = (CompoundButton) editShareView.findViewById(R.id.canShareSwitch); compound.setOnCheckedChangeListener(changeListener); compound = (CompoundButton) editShareView.findViewById(R.id.canEditSwitch); compound.setOnCheckedChangeListener(changeListener); if (mFile.isFolder()) { compound = (CompoundButton) editShareView.findViewById(R.id.canEditCreateCheckBox); compound.setOnCheckedChangeListener(changeListener); compound = (CompoundButton) editShareView.findViewById(R.id.canEditChangeCheckBox); compound.setOnCheckedChangeListener(changeListener); compound = (CompoundButton) editShareView.findViewById(R.id.canEditDeleteCheckBox); compound.setOnCheckedChangeListener(changeListener); } }
4. ListMenuItemView#setChecked()
Project: Ushahidi_Android
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setChecked(boolean checked) { CompoundButton compoundButton; if (mItemData.isExclusiveCheckable()) { if (mRadioButton == null) { insertRadioButton(); } compoundButton = mRadioButton; } else { if (mCheckBox == null) { insertCheckBox(); } compoundButton = mCheckBox; } compoundButton.setChecked(checked); }
5. ListMenuItemView#setChecked()
Project: todo.txt-android
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setChecked(boolean checked) { CompoundButton compoundButton; if (mItemData.isExclusiveCheckable()) { if (mRadioButton == null) { insertRadioButton(); } compoundButton = mRadioButton; } else { if (mCheckBox == null) { insertCheckBox(); } compoundButton = mCheckBox; } compoundButton.setChecked(checked); }
6. PXVirtualCompoundButtonIconAdapter#updateStyle()
Project: pixate-freestyle-android
File: PXVirtualCompoundButtonIconAdapter.java
File: PXVirtualCompoundButtonIconAdapter.java
/* * (non-Javadoc) * @see * com.pixate.freestyle.styling.adapters.PXStyleAdapter#updateStyle(java. * util.List, java.util.List) */ @Override public boolean updateStyle(List<PXRuleSet> ruleSets, List<PXStylerContext> contexts) { if (!super.updateStyle(ruleSets, contexts)) { return false; } // Style the compound button background image. We will construct the // drawable from then context states, and then set the constructed // drawable as a buttons-background using the // CompoundButton#setButtonBackground(Drawable) call. Note that this is // different than the View#setBackground(Drawable) call that is handled // in the default View adapter. CompoundButton view = (CompoundButton) contexts.get(0).getStyleable(); // Grab the existing states. Map<int[], Drawable> existingStates = PXDrawableUtil.getExistingStates(getBackgroundDrawable(view)); // Generate the new StateListDrawable and set it as the button's // drawable. view.setButtonDrawable(PXDrawableUtil.createDrawable(this, existingStates, ruleSets, contexts)); return true; }
7. ListMenuItemView#setChecked()
Project: networklog
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setChecked(boolean checked) { CompoundButton compoundButton; if (mItemData.isExclusiveCheckable()) { if (mRadioButton == null) { insertRadioButton(); } compoundButton = mRadioButton; } else { if (mCheckBox == null) { insertCheckBox(); } compoundButton = mCheckBox; } compoundButton.setChecked(checked); }
8. ListMenuItemView#setChecked()
Project: Libraries-for-Android-Developers
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setChecked(boolean checked) { CompoundButton compoundButton; if (mItemData.isExclusiveCheckable()) { if (mRadioButton == null) { insertRadioButton(); } compoundButton = mRadioButton; } else { if (mCheckBox == null) { insertCheckBox(); } compoundButton = mCheckBox; } compoundButton.setChecked(checked); }
9. ListMenuItemView#setChecked()
Project: HoloEverywhere
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setChecked(boolean checked) { CompoundButton compoundButton; if (mItemData.isExclusiveCheckable()) { if (mRadioButton == null) { insertRadioButton(); } compoundButton = mRadioButton; } else { if (mCheckBox == null) { insertCheckBox(); } compoundButton = mCheckBox; } compoundButton.setChecked(checked); }
10. ListMenuItemView#setChecked()
Project: astrid
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setChecked(boolean checked) { CompoundButton compoundButton; if (mItemData.isExclusiveCheckable()) { if (mRadioButton == null) { insertRadioButton(); } compoundButton = mRadioButton; } else { if (mCheckBox == null) { insertCheckBox(); } compoundButton = mCheckBox; } compoundButton.setChecked(checked); }
11. ListMenuItemView#setChecked()
Project: ActionBarSherlock
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setChecked(boolean checked) { CompoundButton compoundButton; if (mItemData.isExclusiveCheckable()) { if (mRadioButton == null) { insertRadioButton(); } compoundButton = mRadioButton; } else { if (mCheckBox == null) { insertCheckBox(); } compoundButton = mCheckBox; } compoundButton.setChecked(checked); }
12. StepEditActivity#onPrepareOptionsMenu()
Project: iFixitAndroid
File: StepEditActivity.java
File: StepEditActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem viewGuide = menu.findItem(R.id.view_guide); MenuItem visibilityToggle = menu.findItem(R.id.publish_guide); CompoundButton toggle = ((CompoundButton) visibilityToggle.getActionView().findViewById(R.id.publish_toggle)); if (mGuide != null) { if (mGuide.getRevisionid() == null) { viewGuide.setIcon(R.drawable.ic_action_book_dark); viewGuide.setEnabled(false); toggle.setEnabled(false); } else { viewGuide.setIcon(R.drawable.ic_action_book); viewGuide.setEnabled(true); toggle.setEnabled(true); if (toggle.isChecked() != mGuide.isPublic()) toggle.setChecked(mGuide.isPublic()); } } else { viewGuide.setIcon(R.drawable.ic_action_book_dark); viewGuide.setEnabled(false); toggle.setEnabled(false); } return super.onPrepareOptionsMenu(menu); }
13. ImportanceControlSet#setImportance()
Project: astrid
File: ImportanceControlSet.java
File: ImportanceControlSet.java
public void setImportance(Integer i) { for (CompoundButton b : buttons) { if (b.getTag() == i) { b.setChecked(true); b.setBackgroundResource(ThemeService.getDarkVsLight(R.drawable.importance_background_selected, R.drawable.importance_background_selected_dark, false)); } else { b.setChecked(false); b.setBackgroundResource(0); } } for (ImportanceChangedListener l : listeners) { l.importanceChanged(i, colors[i]); } }
14. OpenMenuView#setMenuItemChecked()
Project: Android-tv-widget
File: OpenMenuView.java
File: OpenMenuView.java
/** * ????item-checked??. */ private void setMenuItemChecked(AdapterView<?> parent, int position) { IOpenMenu openMenu = ((MenuAdpater) parent.getAdapter()).getOpenMenu(); CompoundButton compoundButton = openMenu.getCheckedView(); if (compoundButton != null) { // radiobutton ??????. if (compoundButton instanceof RadioButton) { // radiobutton. for (IOpenMenuItem menuItem : openMenu.getMenuDatas()) { menuItem.setChecked(false); } } // ???true. List<IOpenMenuItem> items = openMenu.getMenuDatas(); if (items == null) return; IOpenMenuItem openMenuItem = items.get(position); if (openMenuItem != null) openMenuItem.setChecked(true); } }
15. ConfigDialog#showProfileConfigDialog()
Project: socialize-sdk-android
File: ConfigDialog.java
File: ConfigDialog.java
public static void showProfileConfigDialog(final Activity mContext) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); final View layout = inflater.inflate(R.layout.profiling, (ViewGroup) mContext.findViewById(R.id.profiling_layout)); final CompoundButton profileActionBar = (CompoundButton) layout.findViewById(R.id.profileActionBar); final CompoundButton profileSettings = (CompoundButton) layout.findViewById(R.id.profileSettings); final CompoundButton profileCommentList = (CompoundButton) layout.findViewById(R.id.profileCommentList); final CompoundButton profileShareDialog = (CompoundButton) layout.findViewById(R.id.profileShareDialog); profileActionBar.setChecked(Debug.profileActionBar); profileSettings.setChecked(Debug.profileSettings); profileCommentList.setChecked(Debug.profileCommentList); profileShareDialog.setChecked(Debug.profileShareDialog); AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setTitle("Android Profiling"); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Debug.profileActionBar = profileActionBar.isChecked(); Debug.profileSettings = profileSettings.isChecked(); Debug.profileCommentList = profileCommentList.isChecked(); Debug.profileShareDialog = profileShareDialog.isChecked(); dialog.dismiss(); showConfigDialog(mContext); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); showConfigDialog(mContext); } }); builder.setView(layout); AlertDialog dialog = builder.create(); dialog.show(); }
16. TogglesResult#display()
Project: KISS
File: TogglesResult.java
File: TogglesResult.java
@SuppressWarnings({ "ResourceType", "deprecation" }) @Override public View display(Context context, int position, View v) { // On first run, initialize handler if (togglesHandler == null) togglesHandler = new TogglesHandler(context); if (v == null) v = inflateFromId(context, R.layout.item_toggle); String togglePrefix = "<small><small>" + context.getString(R.string.toggles_prefix) + "</small></small>"; TextView toggleName = (TextView) v.findViewById(R.id.item_toggle_name); toggleName.setText(TextUtils.concat(Html.fromHtml(togglePrefix), enrichText(togglePojo.displayName))); ImageView toggleIcon = (ImageView) v.findViewById(R.id.item_toggle_icon); toggleIcon.setImageDrawable(context.getResources().getDrawable(togglePojo.icon)); toggleIcon.setColorFilter(getThemeFillColor(context), Mode.SRC_IN); // Use the handler to check or un-check button final CompoundButton toggleButton = (CompoundButton) v.findViewById(R.id.item_toggle_action_toggle); //set listener to null to avoid calling the listener of the older toggle item //(due to recycling) toggleButton.setOnCheckedChangeListener(null); Boolean state = togglesHandler.getState(togglePojo); if (state != null) toggleButton.setChecked(togglesHandler.getState(togglePojo)); else toggleButton.setEnabled(false); toggleButton.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!togglesHandler.getState(togglePojo).equals(toggleButton.isChecked())) { // record launch manually recordLaunch(buttonView.getContext()); togglesHandler.setState(togglePojo, toggleButton.isChecked()); toggleButton.setEnabled(false); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { try { Thread.sleep(1500); } catch (InterruptedException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); toggleButton.setEnabled(true); } }.execute(); } } }); return v; }
17. ListMenuItemView#setCheckable()
Project: Ushahidi_Android
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setCheckable(boolean checkable) { if (!checkable && mRadioButton == null && mCheckBox == null) { return; } if (mRadioButton == null) { insertRadioButton(); } if (mCheckBox == null) { insertCheckBox(); } // Depending on whether its exclusive check or not, the checkbox or // radio button will be the one in use (and the other will be otherCompoundButton) final CompoundButton compoundButton; final CompoundButton otherCompoundButton; if (mItemData.isExclusiveCheckable()) { compoundButton = mRadioButton; otherCompoundButton = mCheckBox; } else { compoundButton = mCheckBox; otherCompoundButton = mRadioButton; } if (checkable) { compoundButton.setChecked(mItemData.isChecked()); final int newVisibility = checkable ? VISIBLE : GONE; if (compoundButton.getVisibility() != newVisibility) { compoundButton.setVisibility(newVisibility); } // Make sure the other compound button isn't visible if (otherCompoundButton.getVisibility() != GONE) { otherCompoundButton.setVisibility(GONE); } } else { mCheckBox.setVisibility(GONE); mRadioButton.setVisibility(GONE); } }
18. ListMenuItemView#setCheckable()
Project: todo.txt-android
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setCheckable(boolean checkable) { if (!checkable && mRadioButton == null && mCheckBox == null) { return; } if (mRadioButton == null) { insertRadioButton(); } if (mCheckBox == null) { insertCheckBox(); } // Depending on whether its exclusive check or not, the checkbox or // radio button will be the one in use (and the other will be otherCompoundButton) final CompoundButton compoundButton; final CompoundButton otherCompoundButton; if (mItemData.isExclusiveCheckable()) { compoundButton = mRadioButton; otherCompoundButton = mCheckBox; } else { compoundButton = mCheckBox; otherCompoundButton = mRadioButton; } if (checkable) { compoundButton.setChecked(mItemData.isChecked()); final int newVisibility = checkable ? VISIBLE : GONE; if (compoundButton.getVisibility() != newVisibility) { compoundButton.setVisibility(newVisibility); } // Make sure the other compound button isn't visible if (otherCompoundButton.getVisibility() != GONE) { otherCompoundButton.setVisibility(GONE); } } else { mCheckBox.setVisibility(GONE); mRadioButton.setVisibility(GONE); } }
19. ListMenuItemView#setCheckable()
Project: networklog
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setCheckable(boolean checkable) { if (!checkable && mRadioButton == null && mCheckBox == null) { return; } if (mRadioButton == null) { insertRadioButton(); } if (mCheckBox == null) { insertCheckBox(); } // Depending on whether its exclusive check or not, the checkbox or // radio button will be the one in use (and the other will be otherCompoundButton) final CompoundButton compoundButton; final CompoundButton otherCompoundButton; if (mItemData.isExclusiveCheckable()) { compoundButton = mRadioButton; otherCompoundButton = mCheckBox; } else { compoundButton = mCheckBox; otherCompoundButton = mRadioButton; } if (checkable) { compoundButton.setChecked(mItemData.isChecked()); final int newVisibility = checkable ? VISIBLE : GONE; if (compoundButton.getVisibility() != newVisibility) { compoundButton.setVisibility(newVisibility); } // Make sure the other compound button isn't visible if (otherCompoundButton.getVisibility() != GONE) { otherCompoundButton.setVisibility(GONE); } } else { mCheckBox.setVisibility(GONE); mRadioButton.setVisibility(GONE); } }
20. ListMenuItemView#setCheckable()
Project: Libraries-for-Android-Developers
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setCheckable(boolean checkable) { if (!checkable && mRadioButton == null && mCheckBox == null) { return; } if (mRadioButton == null) { insertRadioButton(); } if (mCheckBox == null) { insertCheckBox(); } // Depending on whether its exclusive check or not, the checkbox or // radio button will be the one in use (and the other will be otherCompoundButton) final CompoundButton compoundButton; final CompoundButton otherCompoundButton; if (mItemData.isExclusiveCheckable()) { compoundButton = mRadioButton; otherCompoundButton = mCheckBox; } else { compoundButton = mCheckBox; otherCompoundButton = mRadioButton; } if (checkable) { compoundButton.setChecked(mItemData.isChecked()); final int newVisibility = checkable ? VISIBLE : GONE; if (compoundButton.getVisibility() != newVisibility) { compoundButton.setVisibility(newVisibility); } // Make sure the other compound button isn't visible if (otherCompoundButton.getVisibility() != GONE) { otherCompoundButton.setVisibility(GONE); } } else { mCheckBox.setVisibility(GONE); mRadioButton.setVisibility(GONE); } }
21. StepEditActivity#onCreateOptionsMenu()
Project: iFixitAndroid
File: StepEditActivity.java
File: StepEditActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getSupportMenuInflater().inflate(R.menu.step_edit_menu, menu); MenuItem item = menu.findItem(R.id.publish_guide); CompoundButton toggle = (CompoundButton) item.getActionView().findViewById(R.id.publish_toggle); toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (mGuide != null && !mGuide.isNewGuide() && isChecked != mGuide.isPublic()) { // Disable the toggle so we don't have multiple presses. buttonView.setEnabled(false); // Disable the switch / checkbox until the publish response comes back. //buttonView.setEnabled(false); showLoading(mLoadingContainer, getString(isChecked ? R.string.publishing : R.string.unpublishing)); if (isChecked) { Api.call(StepEditActivity.this, ApiCall.publishGuide(mGuide.getGuideid(), mGuide.getRevisionid())); } else { Api.call(StepEditActivity.this, ApiCall.unpublishGuide(mGuide.getGuideid(), mGuide.getRevisionid())); } } } }); return super.onCreateOptionsMenu(menu); }
22. ListMenuItemView#setCheckable()
Project: HoloEverywhere
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setCheckable(boolean checkable) { if (!checkable && mRadioButton == null && mCheckBox == null) { return; } // Depending on whether its exclusive check or not, the checkbox or // radio button will be the one in use (and the other will be otherCompoundButton) final CompoundButton compoundButton; final CompoundButton otherCompoundButton; if (mItemData.isExclusiveCheckable()) { if (mRadioButton == null) { insertRadioButton(); } compoundButton = mRadioButton; otherCompoundButton = mCheckBox; } else { if (mCheckBox == null) { insertCheckBox(); } compoundButton = mCheckBox; otherCompoundButton = mRadioButton; } if (checkable) { compoundButton.setChecked(mItemData.isChecked()); final int newVisibility = checkable ? VISIBLE : GONE; if (compoundButton.getVisibility() != newVisibility) { compoundButton.setVisibility(newVisibility); } // Make sure the other compound button isn't visible if (otherCompoundButton != null && otherCompoundButton.getVisibility() != GONE) { otherCompoundButton.setVisibility(GONE); } } else { if (mCheckBox != null) { mCheckBox.setVisibility(GONE); } if (mRadioButton != null) { mRadioButton.setVisibility(GONE); } } }
23. LanguagesActivity#onCreate()
Project: Gitskarios
File: LanguagesActivity.java
File: LanguagesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.languages_activity); if (getToolbar() != null) { ViewCompat.setElevation(getToolbar(), getResources().getDimension(R.dimen.gapSmall)); } RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler); recyclerView.setLayoutManager(new GridLayoutManager(this, 2)); adapter = new LanguagesAdapter(LayoutInflater.from(this)); adapter.setLanguageSelectedListener(this); recyclerView.setAdapter(adapter); CompoundButton switchAllLanguages = (CompoundButton) findViewById(R.id.allLanguagesSwitch); loadList(false); switchAllLanguages.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { loadList(isChecked); } }); }
24. ListMenuItemView#setCheckable()
Project: astrid
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setCheckable(boolean checkable) { if (!checkable && mRadioButton == null && mCheckBox == null) { return; } if (mRadioButton == null) { insertRadioButton(); } if (mCheckBox == null) { insertCheckBox(); } // Depending on whether its exclusive check or not, the checkbox or // radio button will be the one in use (and the other will be otherCompoundButton) final CompoundButton compoundButton; final CompoundButton otherCompoundButton; if (mItemData.isExclusiveCheckable()) { compoundButton = mRadioButton; otherCompoundButton = mCheckBox; } else { compoundButton = mCheckBox; otherCompoundButton = mRadioButton; } if (checkable) { compoundButton.setChecked(mItemData.isChecked()); final int newVisibility = checkable ? VISIBLE : GONE; if (compoundButton.getVisibility() != newVisibility) { compoundButton.setVisibility(newVisibility); } // Make sure the other compound button isn't visible if (otherCompoundButton.getVisibility() != GONE) { otherCompoundButton.setVisibility(GONE); } } else { mCheckBox.setVisibility(GONE); mRadioButton.setVisibility(GONE); } }
25. ViewFinder#onCheck()
Project: AndroidStudyDemo
File: ViewFinder.java
File: ViewFinder.java
/** * Register on checked change listener to child view with given id * * @param id * @param listener * @return view registered with listener */ public CompoundButton onCheck(final int id, final OnCheckedChangeListener listener) { CompoundButton checkable = find(id); checkable.setOnCheckedChangeListener(listener); return checkable; }
26. ListMenuItemView#setCheckable()
Project: ActionBarSherlock
File: ListMenuItemView.java
File: ListMenuItemView.java
public void setCheckable(boolean checkable) { if (!checkable && mRadioButton == null && mCheckBox == null) { return; } if (mRadioButton == null) { insertRadioButton(); } if (mCheckBox == null) { insertCheckBox(); } // Depending on whether its exclusive check or not, the checkbox or // radio button will be the one in use (and the other will be otherCompoundButton) final CompoundButton compoundButton; final CompoundButton otherCompoundButton; if (mItemData.isExclusiveCheckable()) { compoundButton = mRadioButton; otherCompoundButton = mCheckBox; } else { compoundButton = mCheckBox; otherCompoundButton = mRadioButton; } if (checkable) { compoundButton.setChecked(mItemData.isChecked()); final int newVisibility = checkable ? VISIBLE : GONE; if (compoundButton.getVisibility() != newVisibility) { compoundButton.setVisibility(newVisibility); } // Make sure the other compound button isn't visible if (otherCompoundButton.getVisibility() != GONE) { otherCompoundButton.setVisibility(GONE); } } else { mCheckBox.setVisibility(GONE); mRadioButton.setVisibility(GONE); } }
27. ImportanceControlSet#getImportance()
Project: astrid
File: ImportanceControlSet.java
File: ImportanceControlSet.java
public Integer getImportance() { for (CompoundButton b : buttons) if (b.isChecked()) return (Integer) b.getTag(); return null; }