本文整理匯總了Java中android.widget.CheckBox.isChecked方法的典型用法代碼示例。如果您正苦於以下問題:Java CheckBox.isChecked方法的具體用法?Java CheckBox.isChecked怎麽用?Java CheckBox.isChecked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.CheckBox
的用法示例。
在下文中一共展示了CheckBox.isChecked方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: question_1
import android.widget.CheckBox; //導入方法依賴的package包/類
/**
* This method counter correct answers in question 1
* "Which of the following are the primary goals of network security? (Choose 3 best answers)"
*/
public void question_1() {
// Figure out if the user chose "Availability" answer
CheckBox AvailabilityCheckBox = (CheckBox) findViewById(R.id.availability_checkbox);
boolean hasAvailability = AvailabilityCheckBox.isChecked();
if (hasAvailability) {
increment_score();
}
// Figure out if the user chose "Integrity" answer
CheckBox IntegrityCheckBox = (CheckBox) findViewById(R.id.integrity_checkbox);
boolean hasIntegrity = IntegrityCheckBox.isChecked();
if (hasIntegrity) {
increment_score();
}
// Figure out if the user chose "Confidentiality" answer
CheckBox ConfidentialityCheckBox = (CheckBox) findViewById(R.id.confidentiality_checkbox);
boolean hasConfidentiality = ConfidentialityCheckBox.isChecked();
if (hasConfidentiality) {
increment_score();
}
}
示例2: LightSettings
import android.widget.CheckBox; //導入方法依賴的package包/類
LightSettings(List<CheckBox> checkBoxes) {
String lights = null;
String colors = null;
for (CheckBox cb : checkBoxes) {
if (cb.isChecked()) {
if (lights == null) {
lights = String
.valueOf(((int[]) cb.getTag())[0]);
colors = String
.valueOf(((int[]) cb.getTag())[1]);
} else {
lights += "," + ((int[]) cb.getTag())[0];
colors += "," + ((int[]) cb.getTag())[1];
}
}
}
this.lights = Util.toIntArray(lights);
this.colors = Util.toIntArray(colors);
}
示例3: submitOrder
import android.widget.CheckBox; //導入方法依賴的package包/類
/**
* This method is called when the order button is clicked.
*/
public void submitOrder(View view) {
EditText nameField = findViewById(R.id.name_field);
String name = nameField.getText().toString();
Log.v("MainActivity", "Name: " + name);
// Figure out if the user wants whipped cream topping
CheckBox whippedCreamCheckBox = findViewById(R.id.whipped_cream_checkbox);
boolean hasWhippedCream = whippedCreamCheckBox.isChecked();
// Figure out if the user wants chocolate topping
CheckBox chocolateCheckBox = findViewById(R.id.chocolate_checkbox);
boolean hasChocolate = chocolateCheckBox.isChecked();
// Calculate the price
int price = calculatePrice(hasWhippedCream, hasChocolate);
String priceMessage = createOrderSummary(name, price, hasWhippedCream, hasChocolate);
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_SUBJECT, "Just Java order for " + name);
intent.putExtra(Intent.EXTRA_TEXT, priceMessage);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
開發者ID:ItalianCoder,項目名稱:Google-Developer-Challenge-Scholarship-Android-Basics,代碼行數:30,代碼來源:MainActivity.java
示例4: checkGenderSelected
import android.widget.CheckBox; //導入方法依賴的package包/類
private void checkGenderSelected( final CheckBox mGenderPreferenceCheckBoxFemale, final CheckBox mGenderPreferenceCheckBoxMale, final CheckBox mGenderPreferenceCheckBoxNonbinary,
final CheckBox mGenderPreferenceCheckBoxOther ) {
if (!mGenderPreferenceCheckBoxMale.isChecked() && !mGenderPreferenceCheckBoxFemale.isChecked() &&
!mGenderPreferenceCheckBoxOther.isChecked() && !mGenderPreferenceCheckBoxNonbinary.isChecked()){
errorFlag = true;
mGenderPreferenceCheckBoxMale.setTextColor((getResources().getColor(R.color.colorSignUpError)));
mGenderPreferenceCheckBoxFemale.setTextColor((getResources().getColor(R.color.colorSignUpError)));
mGenderPreferenceCheckBoxOther.setTextColor((getResources().getColor(R.color.colorSignUpError)));
mGenderPreferenceCheckBoxNonbinary.setTextColor((getResources().getColor(R.color.colorSignUpError)));
} else {
mGenderPreferenceCheckBoxMale.setTextColor(getResources().getColor(R.color.common_google_signin_btn_text_light));
mGenderPreferenceCheckBoxFemale.setTextColor(getResources().getColor(R.color.common_google_signin_btn_text_light));
mGenderPreferenceCheckBoxOther.setTextColor(getResources().getColor(R.color.common_google_signin_btn_text_light));
mGenderPreferenceCheckBoxNonbinary.setTextColor(getResources().getColor(R.color.common_google_signin_btn_text_light));
}
}
示例5: check1
import android.widget.CheckBox; //導入方法依賴的package包/類
public void check1(View view) {
//checkbox 1
CheckBox mandarino_uno = (CheckBox) findViewById(R.id.vota1);
//checkbox 2
CheckBox mandarino_due = (CheckBox) findViewById(R.id.vota2);
//checkbox 3
CheckBox mandarino_tre = (CheckBox) findViewById(R.id.vota3);
mandarino_uno_checked=mandarino_uno.isChecked();
if(mandarino_uno_checked) {
orange = 1;
mandarino_due.setChecked(false);
mandarino_tre.setChecked(false);
}else{
orange=0;
}
}
示例6: check2
import android.widget.CheckBox; //導入方法依賴的package包/類
public void check2(View view) {
//checkbox 1
CheckBox mandarino_uno = (CheckBox) findViewById(R.id.vota1);
//checkbox 2
CheckBox mandarino_due = (CheckBox) findViewById(R.id.vota2);
//checkbox 3
CheckBox mandarino_tre = (CheckBox) findViewById(R.id.vota3);
mandarino_due_checked=mandarino_due.isChecked();
if(mandarino_due_checked) {
orange = 2;
mandarino_uno.setChecked(false);
mandarino_tre.setChecked(false);
}else{
orange=0;
}
}
示例7: question_9
import android.widget.CheckBox; //導入方法依賴的package包/類
/**
* This method counter correct answers in question 9
* "Which of the following are the Integrity attacks? (Choose 3 best answers)"
*/
public void question_9() {
// Figure out if the user chose "Data diddling" answer
CheckBox DataDiddlingCheckBox = (CheckBox) findViewById(R.id.data_diddling_checkbox);
boolean hasDataDiddlingCheckBox = DataDiddlingCheckBox.isChecked();
if (hasDataDiddlingCheckBox) {
increment_score();
}
// Figure out if the user chose "Password attack" answer
CheckBox PasswordAttackCheckBox = (CheckBox) findViewById(R.id.password_attack_9_checkbox);
boolean hasPasswordAttackCheckBox = PasswordAttackCheckBox.isChecked();
if (hasPasswordAttackCheckBox) {
increment_score();
}
// Figure out if the user chose "Botnet" answer
CheckBox BotnetCheckBox = (CheckBox) findViewById(R.id.botnet_9_checkbox);
boolean hasBotnetCheckBox = BotnetCheckBox.isChecked();
if (hasBotnetCheckBox) {
increment_score();
}
}
示例8: submitOrder
import android.widget.CheckBox; //導入方法依賴的package包/類
/**
* This method is called when the order button is clicked.
*/
public void submitOrder(View view) {
CheckBox whippedCreamCheckBox = findViewById(R.id.whipped_cream_checkbox);
boolean hasWhippedCream = whippedCreamCheckBox.isChecked();
Log.v("MainActivity", "Has whipped cream: " + hasWhippedCream);
int price = calculatePrice();
displayMessage(createOrderSummary(price, hasWhippedCream));
}
開發者ID:ItalianCoder,項目名稱:Google-Developer-Challenge-Scholarship-Android-Basics,代碼行數:12,代碼來源:MainActivity.java
示例9: canMoveFurther
import android.widget.CheckBox; //導入方法依賴的package包/類
@Override
public boolean canMoveFurther() {
checkBox = (CheckBox) getActivity().findViewById(R.id.cb_concordo);
if (checkBox.isChecked()) {
SharedPreferencesUtil.updateIntroStatus(getContext(), true);
Intent intent = new Intent(getActivity(), MapActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
getActivity().finish();
}
return checkBox.isChecked();
}
示例10: refresh
import android.widget.CheckBox; //導入方法依賴的package包/類
void refresh() {
for (int i = 0; i < views.length; i++) {
if (views[i] != null) {
Fach current = fachArray[i];
CheckBox c = cbs[i];
TextView tvFach = views[i].findViewById(R.id.fach_auswahl);
TextView tvKuerzel = views[i].findViewById(R.id.kürzel_auswahl);
TextView tvLehrer = views[i].findViewById(R.id.lehrer_auswahl);
if (c.isChecked()) {
views[i].setEnabled(true);
tvFach.setTextColor(ContextCompat.getColor(getContext(), R.color.colorAccent));
tvKuerzel.setTextColor(ContextCompat.getColor(getContext(), R.color.colorAccent));
tvLehrer.setTextColor(ContextCompat.getColor(getContext(), R.color.colorAccent));
} else if (ausgewaehlteStunden[current.getTag() - 1][current.getStunde() - 1] || (current.getKuerzel().startsWith("IB") ? ausgewaehlteFaecher.contains(current.getKuerzel().substring(3, 6)) : ausgewaehlteFaecher.contains(current.getKuerzel().substring(0, 2)))) {
views[i].setEnabled(false);
tvFach.setTextColor(ContextCompat.getColor(getContext(), R.color.colorTextGreyed));
tvKuerzel.setTextColor(ContextCompat.getColor(getContext(), R.color.colorTextGreyed));
tvLehrer.setTextColor(ContextCompat.getColor(getContext(), R.color.colorTextGreyed));
} else {
views[i].setEnabled(true);
tvFach.setTextColor(ContextCompat.getColor(getContext(), R.color.colorText));
tvKuerzel.setTextColor(ContextCompat.getColor(getContext(), R.color.colorText));
tvLehrer.setTextColor(ContextCompat.getColor(getContext(), R.color.colorText));
}
}
}
}
示例11: confirmCombatAction
import android.widget.CheckBox; //導入方法依賴的package包/類
@Override
protected void confirmCombatAction(InputMethodManager mgr, View addCombatantView) {
CheckBox unarmedValue = addCombatantView.findViewById(R.id.unarmedValue);
unarmed = unarmedValue.isChecked();
super.confirmCombatAction(mgr, addCombatantView);
}
示例12: onClickCheckBox
import android.widget.CheckBox; //導入方法依賴的package包/類
@Override
public void onClickCheckBox(int p,CheckBox checkBox,TextView title)
{
HashMap<String,String> map = mArrayList.get(p);
if(checkBox.isChecked())
{
title.setPaintFlags(title.getPaintFlags()|Paint.STRIKE_THRU_TEXT_FLAG);
MediaPlayer player = MediaPlayer.create(getContext(),R.raw.ding);
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
if(player.isPlaying())
player.stop();
else
player.start();
mTodo.updateData(keyName,1,map.get("id"));
mArrayList = mTodo.getData(keyName);
}
else
{
title.setPaintFlags(title.getPaintFlags()&(~Paint.STRIKE_THRU_TEXT_FLAG));
mTodo.updateData(keyName,0,map.get("id"));
mArrayList = mTodo.getData(keyName);
}
}
示例13: finish
import android.widget.CheckBox; //導入方法依賴的package包/類
/**
* Return the details of the new habit to the calling activity
* so that the habit can be created and added to the habit list.
*/
@Override
public void finish(){
Intent data = new Intent();
if (save){
EditText name = (EditText) findViewById(R.id.titleEditText);
EditText reason = (EditText) findViewById(R.id.reasonEditText);
//Change days into a sequence of 1's and 0's
//ie 1001100 = Sunday, Wednesday, Thursday.
ArrayList<CheckBox> days = new ArrayList<CheckBox>();
days.add((CheckBox) findViewById(R.id.sundayBox));
days.add((CheckBox) findViewById(R.id.mondayBox));
days.add((CheckBox) findViewById(R.id.tuesdayBox));
days.add((CheckBox) findViewById(R.id.wednesdayBox));
days.add((CheckBox) findViewById(R.id.thursdayBox));
days.add((CheckBox) findViewById(R.id.fridayBox));
days.add((CheckBox) findViewById(R.id.saturdayBox));
String schedule = "";
for (int i=0; i<days.size(); i++){
CheckBox b = days.get(i);
if (b != null){
if (b.isChecked()){
schedule += "1";
}else{
schedule += "0";
}
}
}
data.putExtra(MainActivity.EXTRA_HABIT_NAME, name.getText().toString());
data.putExtra(MainActivity.EXTRA_HABIT_REASON, reason.getText().toString());
data.putExtra(MainActivity.EXTRA_HABIT_STARTDATE, newdate.getTime());
data.putExtra(MainActivity.EXTRA_HABIT_SCHEDULE, schedule);
}
setResult(RESULT_OK, data);
super.finish();
}
示例14: onFlatShadingClicked
import android.widget.CheckBox; //導入方法依賴的package包/類
public void onFlatShadingClicked(@SuppressWarnings("unused") View unused) {
CheckBox cb = (CheckBox) findViewById(R.id.flatShading_checkbox);
mFlatShadingChecked = cb.isChecked();
RenderHandler rh = mRenderThread.getHandler();
if (rh != null) {
rh.sendSetFlatShading(mFlatShadingChecked);
}
}
示例15: submitOrder
import android.widget.CheckBox; //導入方法依賴的package包/類
/**
* This method is called when the order button is clicked.
*/
public void submitOrder(View view) {
EditText nameField = (EditText) findViewById(R.id.name_field);
String name = nameField.getText().toString();
// Figure out if the user wants whipped cream topping
CheckBox whippedCreamCheckBox = (CheckBox) findViewById(R.id.whipped_cream_checkbox);
boolean hasWhippedCream = whippedCreamCheckBox.isChecked();
// Figure out if the user wants whipped cream topping
CheckBox ChocolateCheckBox = (CheckBox) findViewById(R.id.chocolate_checkbox);
boolean hasChocolate = ChocolateCheckBox.isChecked();
// Calculate the price
int price = calculatePrice(hasWhippedCream, hasChocolate);
// Display the order summary on the screen
String priceMessage = createOrderSummary(name, price, hasWhippedCream, hasChocolate);
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.email) + name);
intent.putExtra(Intent.EXTRA_TEXT, priceMessage);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}