当前位置: 首页>>代码示例>>Java>>正文


Java CheckBox.setEnabled方法代码示例

本文整理汇总了Java中android.widget.CheckBox.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java CheckBox.setEnabled方法的具体用法?Java CheckBox.setEnabled怎么用?Java CheckBox.setEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.CheckBox的用法示例。


在下文中一共展示了CheckBox.setEnabled方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onResume

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
protected void onResume() {
    super.onResume();
    //initialise location permissions checkbox
    CheckBox locationPermissionsCheckBox = (CheckBox) findViewById(R.id.location_permission_checkbox);
    if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED){
        locationPermissionsCheckBox.setChecked(false);
    }
    else {
        locationPermissionsCheckBox.setChecked(true);
        locationPermissionsCheckBox.setEnabled(false);
    }

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    if (Build.VERSION.SDK_INT>=24 && !notificationManager.isNotificationPolicyAccessGranted()){
        mRingerPermissionCheckBox.setChecked(false);
    }
    else {
        mRingerPermissionCheckBox.setChecked(true);
        mRingerPermissionCheckBox.setEnabled(false);
    }
}
 
开发者ID:samagra14,项目名称:Shush,代码行数:23,代码来源:MainActivity.java

示例2: onCreate

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_cauton);

    getSupportActionBar()
            .setSubtitle(R.string.lic);

    CheckBox cau = (CheckBox) findViewById(R.id.cau);
    if (cau.isChecked()) {
        cau.setEnabled(false);
    }
}
 
开发者ID:AlexanderKirillov,项目名称:Script-Executor-ROOT,代码行数:14,代码来源:License.java

示例3: updateOptions

import android.widget.CheckBox; //导入方法依赖的package包/类
public void updateOptions(View view, boolean enabled) {
	CheckBox stringTransposition = (CheckBox) view.findViewById(R.id.track_tuning_dlg_options_transpose);
	CheckBox stringTranspositionApplyToChords = (CheckBox) view.findViewById(R.id.track_tuning_dlg_options_transpose_apply_to_chords);
	CheckBox stringTranspositionTryKeepString = (CheckBox) view.findViewById(R.id.track_tuning_dlg_options_transpose_try_keep_strings);
	
	boolean stringTranspositionChecked = stringTransposition.isChecked();
	
	stringTransposition.setEnabled(enabled);
	stringTranspositionApplyToChords.setEnabled(enabled && stringTranspositionChecked);
	stringTranspositionTryKeepString.setEnabled(enabled && stringTranspositionChecked);
	if(!stringTranspositionChecked ) {
		stringTranspositionApplyToChords.setChecked(false);
		stringTranspositionTryKeepString.setChecked(false);
	}
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:16,代码来源:TGTrackTuningDialog.java

示例4: setFile

import android.widget.CheckBox; //导入方法依赖的package包/类
@Override
public void setFile(File_POJO file) {
    super.setFile(file);
    CheckBox checkBox = itemView.findViewById(R.id.checkbox);
    checkBox.setTag(file.getPath());
    setOnCheckedChangeListener(null);
    checkBox.setChecked(file.excluded);
    ArrayList<String> excludedPaths = Provider.getExcludedPaths();
    boolean enabled = !Provider.isDirExcludedBecauseParentDirIsExcluded(
            file.getPath(), excludedPaths);
    checkBox.setEnabled(enabled);
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:13,代码来源:ExcludePathsActivity.java

示例5: initView

import android.widget.CheckBox; //导入方法依赖的package包/类
private void initView() {
    removeAllViews();
    for (int i = 0; i < countNum; i++) {
        CheckBox cb = new CheckBox(getContext());
        LayoutParams layoutParams;
        if (widthAndHeight == 0) {
            layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        } else {
            layoutParams = new LayoutParams((int) widthAndHeight, (int) widthAndHeight);
        }
        if (differentSize && countNum % 2 != 0) {
            Log.e("xxx", layoutParams.width + "");
            int index = i;
            if (index > countNum / 2) {
                index = countNum - 1 - index;
            }
            float scale = (index + 1) / (float) (countNum / 2 + 1);
            layoutParams.width = (int) (layoutParams.width * scale);
            layoutParams.height = layoutParams.width;
        }
        layoutParams.gravity = Gravity.CENTER_VERTICAL;
        if (i != 0 && i != countNum - 1) {
            layoutParams.leftMargin = (int) dividerWidth;
            layoutParams.rightMargin = (int) dividerWidth;
        } else if (i == 0) {
            layoutParams.rightMargin = (int) dividerWidth;
        } else if (i == countNum - 1) {
            layoutParams.leftMargin = (int) dividerWidth;
        }
        addView(cb, layoutParams);
        cb.setButtonDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
        if (stateResId == -1) {
            stateResId = R.drawable.book_review_rating_bar_selector;
        }
        cb.setBackgroundResource(stateResId);
        if (i + 1 <= countSelected) {
            cb.setChecked(true);
        }
        cb.setEnabled(canEdit);
        cb.setOnClickListener(new MyClickListener(i));
    }

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:44,代码来源:XLHRatingBar.java

示例6: addItemPrefWithToggle

import android.widget.CheckBox; //导入方法依赖的package包/类
public ItemBuilder addItemPrefWithToggle(Context context, String title, String subtitle, boolean isChecked, boolean useSwitch, boolean isProFeature, boolean userIsPro, String preferenceCONST, String settingsEnabledAction, String settingsDisabledAction) {
    view = inflater.inflate(R.layout.item_element_title_subtitle_checkbox, parent, false);
    TextView tv = (TextView) view.findViewById(R.id.tv_title);
    tv.setText(title);
    TextView tv2 = (TextView) view.findViewById(R.id.tv_subtitle);
    tv2.setText(subtitle);
    CheckBox     checkboxButton = (CheckBox) view.findViewById(R.id.cb_pref);
    SwitchCompat switchButton   = (SwitchCompat) view.findViewById(R.id.sw_pref);
    checkboxButton.setChecked(isChecked);
    switchButton.setChecked(isChecked);
    if (useSwitch) {
        apply(checkboxButton, GONE);
        apply(switchButton, VISIBLE);
    } else {
        apply(checkboxButton, VISIBLE);
        apply(switchButton, GONE);
    }
    View.OnClickListener listener = view1 -> {
        if (SettingsPreferences.isGenericSettingEnabled(context, preferenceCONST, true)) {
            SettingsPreferences.disableGenericSetting(context, preferenceCONST);
            AnalyticsHelper.getInstance(context).logScreenEvent(SCREEN_SETTINGS, settingsDisabledAction);
            checkboxButton.setChecked(false);
            switchButton.setChecked(false);
        } else {
            SettingsPreferences.enableGenericSetting(context, preferenceCONST);
            AnalyticsHelper.getInstance(context).logScreenEvent(SCREEN_SETTINGS, settingsEnabledAction);
            checkboxButton.setChecked(true);
            switchButton.setChecked(true);
        }
    };
    if (!isProFeature || userIsPro) {
        checkboxButton.setEnabled(true);
        switchButton.setEnabled(true);
        checkboxButton.setOnClickListener(listener);
        switchButton.setOnClickListener(listener);
        view.setOnClickListener(listener);
    } else {
        checkboxButton.setChecked(true);
        switchButton.setChecked(true);
        checkboxButton.setEnabled(false);
        switchButton.setEnabled(false);
    }
    return this;
}
 
开发者ID:albertogiunta,项目名称:justintrain-client-android,代码行数:45,代码来源:ItemBuilder.java

示例7: getCheckBox

import android.widget.CheckBox; //导入方法依赖的package包/类
private static View getCheckBox(Activity activity, LayoutInflater inflater, final SignUpEventOptions options) {
    View view = inflater.inflate(R.layout.event_sign_up_check_box, null);
    FlowLayout ll_check_box = (FlowLayout) view.findViewById(R.id.fl_check_box);
    ((TextView) view.findViewById(R.id.tv_label)).setText(options.getLabel() + (options.isRequired() ? "" : "(选填)") + ":");
    RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMarginEnd(100);
    if (options.getSelectList() == null)
        options.setSelectList(new ArrayList<String>());
    if (!TextUtils.isEmpty(options.getOption())) {
        final String[] list = options.getOption().split(";");
        String[] status = null;
        if (!TextUtils.isEmpty(options.getOptionStatus()))
            status = options.getOptionStatus().split(";");
        for (int i = 0; i < list.length; i++) {
            final CheckBox button = new CheckBox(activity);
            button.setLayoutParams(params);
            button.setText(list[i]);
            boolean enable;
            if (status == null)
                enable = true;
            else if (status.length <= i)
                enable = true;
            else
                enable = "0".equals(status[i]);
            button.setId(i);
            button.setEnabled(enable);
            button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    String item = list[button.getId()];
                    if (isChecked) {
                        options.getSelectList().add(item);
                    } else {
                        options.getSelectList().remove(item);
                    }
                }
            });
            ll_check_box.addView(button);
        }
    }
    return view;
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:45,代码来源:ViewFactory.java


注:本文中的android.widget.CheckBox.setEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。