Java Code Examples for android.widget.CheckBox#isChecked()
The following examples show how to use
android.widget.CheckBox#isChecked() .
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: MainActivity.java From screen-dimmer-pixel-filter with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void restartServiceIfNeeded() { final CheckBox c = ((CheckBox) findViewById(R.id.enableFilter)); final boolean wasChecked = c.isChecked(); //Log.d(LOG, "GUI: setting new pattern, checkbox was " + wasChecked); //NON-NLS c.setChecked(false); if (wasChecked || Cfg.PersistentNotification) { new Thread(new Runnable() { public void run() { while (FilterService.running) { try { Thread.sleep(20); } catch (Exception e) {} } runOnUiThread(new Runnable() { @Override public void run() { c.setChecked(true); if (!wasChecked) { c.setChecked(false); } } }); } }).start(); } }
Example 2
Source File: MainActivity.java From AppCrawler with Apache License 2.0 | 6 votes |
public void onStartButtonClick(View view) { // Get selected app list sSelectedAppList = new ArrayList<TargetApp>(); for (int i = 0; i < mListView.getChildCount(); i++) { LinearLayout itemLayout = (LinearLayout) mListView.getChildAt(i); CheckBox cb = (CheckBox) itemLayout.findViewById(R.id.checkBox); if (cb.isChecked()) { TextView pkg = (TextView) itemLayout.findViewById(R.id.appPackage); TextView name = (TextView) itemLayout.findViewById(R.id.appName); TargetApp app = new TargetApp((String) name.getText(), (String) pkg.getText()); sSelectedAppList.add(app); } } Intent intent = new Intent(this, SettingsActivity.class); startActivity(intent); }
Example 3
Source File: MultiplePicker.java From AndroidPicker with MIT License | 6 votes |
@Override protected void onSubmit() { if (onItemPickListener == null) { return; } List<String> checked = new ArrayList<>(); for (int i = 0, count = layout.getChildCount(); i < count; i++) { LinearLayout line = (LinearLayout) layout.getChildAt(i); CheckBox checkBox = (CheckBox) line.getChildAt(1); if (checkBox.isChecked()) { TextView textView = (TextView) line.getChildAt(0); checked.add(textView.getText().toString()); } } onItemPickListener.onItemPicked(checked.size(), checked); }
Example 4
Source File: ServiceListActivity.java From DeviceConnect-Android with MIT License | 6 votes |
/** * ガイドの終了処理を行う. */ private void endGuide() { boolean result = true; CheckBox checkBox = findViewById(R.id.activity_service_guide_checkbox); if (checkBox != null) { result = !checkBox.isChecked(); } setGuideClickable(false); final View guideView = findViewById(R.id.activity_service_guide); if (guideView != null) { AnimationUtil.animateAlpha(guideView, new AnimationUtil.AnimationAdapter() { @Override public void onAnimationEnd(final Animator animation) { guideView.setVisibility(View.GONE); } }); } mSharedData.saveGuideSettings(result); }
Example 5
Source File: MainActivityTest.java From quickstart-android with Apache License 2.0 | 6 votes |
@Test public void caughtExceptionTest() { // Make sure the checkbox is on screen ViewInteraction al = onView( allOf(withId(R.id.catchCrashCheckBox), withText(R.string.catch_crash_checkbox_label), isDisplayed())); // Click the checkbox if it's not already checked CheckBox checkBox = (CheckBox) mActivityTestRule.getActivity() .findViewById(R.id.catchCrashCheckBox); if (!checkBox.isChecked()) { al.perform(click()); } // Cause a crash ViewInteraction ak = onView( allOf(withId(R.id.crashButton), withText(R.string.crash_button_label), isDisplayed())); ak.perform(click()); }
Example 6
Source File: ListMultiWidget.java From commcare-android with Apache License 2.0 | 6 votes |
@Override public IAnswerData getAnswer() { Vector<Selection> vc = new Vector<>(); for (int i = 0; i < mItems.size(); i++) { CheckBox c = findViewById(CHECKBOX_ID + i); if (c.isChecked()) { vc.add(new Selection(mItems.get(i))); } } if (vc.size() == 0) { return null; } else { return new SelectMultiData(vc); } }
Example 7
Source File: SelectMultiWidget.java From commcare-android with Apache License 2.0 | 5 votes |
@Override public void clearAnswer() { int j = mItems.size(); for (int i = 0; i < j; i++) { // no checkbox group so find by id + offset CheckBox c = findViewById(buttonIdBase + i); if (c.isChecked()) { c.setChecked(false); } } }
Example 8
Source File: DisplayAlternativeNovelListActivity.java From coolreader with MIT License | 5 votes |
@Override public boolean onContextItemSelected(android.view.MenuItem item) { switch (item.getItemId()) { case R.id.add_to_watch: /* * Implement code to toggle watch of this novel */ CheckBox checkBox = (CheckBox) findViewById(R.id.novel_is_watched); if (checkBox.isChecked()) { checkBox.setChecked(false); } else { checkBox.setChecked(true); } return true; case R.id.download_novel: /* * Implement code to download novel synopsis */ AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); if (info.position > -1) { PageModel novel = listItems.get(info.position); ArrayList<PageModel> novels = new ArrayList<PageModel>(); novels.add(novel); touchedForDownload = novel.getTitle() + "'s information"; executeDownloadTask(novels); } return true; default: return super.onContextItemSelected(item); } }
Example 9
Source File: AddOrEditBookFragment.java From barterli_android with Apache License 2.0 | 5 votes |
/** * Build the tags array for books * * @return A {@link JSONArray} representing the barter tags */ private JSONArray getBarterTagsArray() { final JSONArray tagNamesArray = new JSONArray(); for (CheckBox checkBox : mBarterTypeCheckBoxes) { if (checkBox.isChecked()) { tagNamesArray.put(checkBox.getTag(R.string.tag_barter_type)); } } return tagNamesArray; }
Example 10
Source File: SettingActivity.java From smartcoins-wallet with MIT License | 5 votes |
Boolean isCHecked(View v) { designMethod(); CheckBox checkBox = (CheckBox) v; if (checkBox.isChecked()) { return true; } return false; }
Example 11
Source File: WriteTag.java From MifareClassicTool with GNU General Public License v3.0 | 5 votes |
/** * Show or hide the options section of write dump. * @param view The View object that triggered the method * (in this case the show options button). */ public void onShowOptions(View view) { LinearLayout ll = findViewById(R.id.linearLayoutWriteTagDumpOptions); CheckBox cb = findViewById(R.id.checkBoxWriteTagDumpOptions); if (cb.isChecked()) { ll.setVisibility(View.VISIBLE); } else { ll.setVisibility(View.GONE); } }
Example 12
Source File: EditBotActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void save(View view) { InstanceConfig instance = new InstanceConfig(); saveProperties(instance); CheckBox checkbox = (CheckBox) findViewById(R.id.forkingCheckBox); instance.allowForking = checkbox.isChecked(); HttpAction action = new HttpUpdateAction(this, instance); action.execute(); }
Example 13
Source File: DisableWifiDialogFragment.java From WiFiAfterConnect with Apache License 2.0 | 5 votes |
protected void performAction (WifiTools.Action action) { Activity activity = getActivity(); DisableWifiDialogListener listener = (DisableWifiDialogListener)activity; if (activity != null) { action.perform(activity); if (listener != null) { CheckBox checkAlways = (CheckBox)activity.findViewById(R.id.checkAlwaysDoThat); if (checkAlways != null && checkAlways.isChecked()) listener.saveAction (action); } activity.finish(); } }
Example 14
Source File: ListMultiWidget.java From commcare-android with Apache License 2.0 | 5 votes |
@Override public void clearAnswer() { int j = mItems.size(); for (int i = 0; i < j; i++) { // no checkbox group so find by id + offset CheckBox c = findViewById(CHECKBOX_ID + i); if (c.isChecked()) { c.setChecked(false); } } }
Example 15
Source File: MainActivity.java From ViewRevealAnimator with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewAnimator = (ViewRevealAnimator) findViewById(R.id.animator); findViewById(R.id.next).setOnClickListener(this); findViewById(R.id.next2).setOnClickListener(this); findViewById(R.id.previous).setOnClickListener(this); CheckBox checkbox = (CheckBox) findViewById(R.id.checkBox); checkbox.setOnCheckedChangeListener(this); mHideBeforeReveal = checkbox.isChecked(); mViewAnimator.setHideBeforeReveal(mHideBeforeReveal); mViewAnimator.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(final View v, final MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { int current = mViewAnimator.getDisplayedChild(); mViewAnimator.setDisplayedChild(current + 1, true, new Point((int) event.getX(), (int) event.getY())); return true; } return false; } }); mViewAnimator.setOnViewChangedListener(this); mViewAnimator.setOnViewAnimationListener(this); }
Example 16
Source File: MainActivity.java From Adafruit_Android_BLE_UART with MIT License | 5 votes |
public void sendClick(View view) { StringBuilder stringBuilder = new StringBuilder(); String message = input.getText().toString(); // We can only send 20 bytes per packet, so break longer messages // up into 20 byte payloads int len = message.length(); int pos = 0; while(len != 0) { stringBuilder.setLength(0); if (len>=20) { stringBuilder.append(message.toCharArray(), pos, 20 ); len-=20; pos+=20; } else { stringBuilder.append(message.toCharArray(), pos, len); len = 0; } uart.send(stringBuilder.toString()); } // Terminate with a newline character if requests newline = (CheckBox) findViewById(R.id.newline); if (newline.isChecked()) { stringBuilder.setLength(0); stringBuilder.append("\n"); uart.send(stringBuilder.toString()); } }
Example 17
Source File: MeDigiSeg.java From Makeblock-App-For-Android with MIT License | 5 votes |
public void setEnable(Handler handler){ mHandler = handler; ed = (EditText) view.findViewById(R.id.editTxt); ed.setEnabled(true); ed.addTextChangedListener(this); synTime = (CheckBox)view.findViewById(R.id.syncTime); synTime.setOnCheckedChangeListener(this); if(synTime.isChecked()){ startTimer(); } sendNumber(ed.getText().toString()); return; }
Example 18
Source File: ExcludedTagNamespacesPreference.java From MHViewer with Apache License 2.0 | 5 votes |
private int getExcludedTagNamespaces(View view) { int newValue = 0; for (int i = 0; i < EXCLUDED_TAG_GROUP_RES_ID.length; i++) { CheckBox cb = (CheckBox) view.findViewById(EXCLUDED_TAG_GROUP_RES_ID[i]); if (cb.isChecked()) { newValue |= EXCLUDED_TAG_GROUP_ID[i]; } } return newValue; }
Example 19
Source File: DoctorPlanAdapter.java From android-apps with MIT License | 4 votes |
@Override public void onClick(View view) { CheckBox cbF = (CheckBox) view; Doctor doctorF =(Doctor)cbF.getTag(); // LinearLayout llLayoutP = (LinearLayout) cbF.getParent(); // get Check box parent layout // LinearLayout llLayoutPL = (LinearLayout) llLayoutP.getParent(); // get xml file parent layout // LinearLayout llLayoutF = (LinearLayout) llLayoutPL.getChildAt(0); // get first linear layout of xml file // // TextView tvDoctorId = (TextView) llLayoutF.getChildAt(1); String doctorId = doctorF.getCode(), freq = doctorF.getFrequency(); //Toast.makeText(context, doctorId + "", 500).show(); //if( DoctorCallPlanCheck.isDoctorAvailable(doctorId,freq) ) { if(view instanceof CheckBox ){ CheckBox cb = (CheckBox) view; Doctor doctor =(Doctor)cb.getTag(); if(cb.isChecked()){ if(cb.getId()==R.id.cbEvning){ doctor.setShift("1"); }else if(cb.getId()==R.id.cbMorning) { doctor.setShift("0"); } //Toast.makeText(context, doctor.getName() + "", 500).show(); doctor.setSelected(true); LinearLayout llLayout = (LinearLayout) cb.getParent(); for(int i=0; i<((ViewGroup)llLayout).getChildCount(); ++i) { View nextChild = ((ViewGroup)llLayout).getChildAt(i); if(nextChild instanceof CheckBox && nextChild.getId()==cb.getId() ){ }else if (nextChild instanceof CheckBox && nextChild.getId()!=cb.getId() ){ CheckBox cb2=(CheckBox) nextChild; cb2.setChecked(false); } } }else{ doctor.setShift("EVENING"); doctor.setSelected(false); } } } // else // { // CheckBox cb = (CheckBox) view; // Doctor doctor =(Doctor)cb.getTag(); // doctor.setSelected(false); // // LinearLayout llLayout = (LinearLayout) cb.getParent(); // // for(int i=0; i<((ViewGroup)llLayout).getChildCount(); ++i) { // View nextChild = ((ViewGroup)llLayout).getChildAt(i); // if(nextChild instanceof CheckBox && nextChild.getId()==cb.getId() ){ // CheckBox cb2=(CheckBox) nextChild; // cb2.setChecked(false); // }else if (nextChild instanceof CheckBox && nextChild.getId()!=cb.getId() ){ // CheckBox cb2=(CheckBox) nextChild; // cb2.setChecked(false); // // } // } // // Toast.makeText(context, "You have already cross max plan/call limit", 700).show(); // } }
Example 20
Source File: ActivitySettings.java From XPrivacy with GNU General Public License v3.0 | 4 votes |
private static String getValue(CheckBox check, EditText edit) { if (check != null && check.isChecked()) return PrivacyManager.cValueRandom; String value = edit.getText().toString().trim(); return ("".equals(value) ? null : value); }