下面列出了android.widget.CheckBox#isChecked ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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);
}
@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);
}
@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());
}
@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);
}
}
/**
* ガイドの終了処理を行う.
*/
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);
}
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();
}
}
@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);
}
}
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;
}
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;
}
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());
}
}
@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);
}
@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);
}
}
}
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();
}
}
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();
}
/**
* 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);
}
}
Boolean isCHecked(View v) {
designMethod();
CheckBox checkBox = (CheckBox) v;
if (checkBox.isChecked()) {
return true;
}
return false;
}
/**
* 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;
}
@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);
}
}
}
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);
}
@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();
// }
}