當前位置: 首頁>>代碼示例>>Java>>正文


Java AppCompatCheckBox.setChecked方法代碼示例

本文整理匯總了Java中android.support.v7.widget.AppCompatCheckBox.setChecked方法的典型用法代碼示例。如果您正苦於以下問題:Java AppCompatCheckBox.setChecked方法的具體用法?Java AppCompatCheckBox.setChecked怎麽用?Java AppCompatCheckBox.setChecked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v7.widget.AppCompatCheckBox的用法示例。


在下文中一共展示了AppCompatCheckBox.setChecked方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
private void init() {
    mRgChoice.setVisibility(View.GONE);
    mChoiceBox.setVisibility(View.VISIBLE);
    mCdTitle.setText(title);
    for (int i = 0; i < datas.length; i++) {
        AppCompatCheckBox cb = new AppCompatCheckBox(mContext);
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(-1, ScreenUtil.getInstance().dip2px(48));
        cb.setLayoutParams(layoutParams);
        cb.setGravity(Gravity.CENTER_VERTICAL);
        cb.setId(i);
        cb.setText(datas[i]);
        cb.setTextSize(15);
        cb.setTextColor(mContext.getResources().getColor(R.color.new_text_color_first));
        cb.setPadding(ScreenUtil.getInstance().dip2px(16), 0, 0, 0);
        if (i == 0)
            cb.setChecked(true);
        mChoiceBox.addView(cb);
    }
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:20,代碼來源:MultiChoiceDialog.java

示例2: onCheckedChanged

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (mConfiguration.getMaxSize() == mMediaActivity.getCheckedList().size() &&
            !mMediaActivity.getCheckedList().contains(mediaBean)) {
        AppCompatCheckBox checkBox = (AppCompatCheckBox) buttonView;
        checkBox.setChecked(false);
        Logger.i("選中:" + mMediaActivity.getResources().getString(R.string.gallery_image_max_size_tip, mConfiguration.getMaxSize()));
        if (iMultiImageCheckedListener != null) {
            iMultiImageCheckedListener.selectedImgMax(buttonView, isChecked, mConfiguration.getMaxSize());
        }
    } else {
        if (iMultiImageCheckedListener != null)
            iMultiImageCheckedListener.selectedImg(buttonView, isChecked);
    }

}
 
開發者ID:Loofer,項目名稱:Watermark,代碼行數:17,代碼來源:MediaGridAdapter.java

示例3: convertCommon

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
@Override
public void convertCommon(ViewHolder viewHolder, final List<AppInfo> appInfo, final int position) {
    super.convertCommon(viewHolder, appInfo, position);
    final AppInfo info = appInfo.get(position);
    viewHolder.setText(R.id.tv_app_package_name, info.getAppPackageName());
    ((TextView) viewHolder.getView(R.id.tv_app_name)).setTextColor(info.isEnable() == 1
            ? mResources.getColor(R.color.textPrimary)
            : mResources.getColor(R.color.translucentBg));
    ((ImageView) viewHolder.getView(R.id.iv_app_icon)).getDrawable().setColorFilter(info.isEnable() == 1
            ? mColorFilterNormal : mColorFilterGrey);
    ((TextView) viewHolder.getView(R.id.tv_app_package_name)).setTextColor(info.isEnable() == 1
            ? mResources.getColor(R.color.textSecondary)
            : mResources.getColor(R.color.translucentBg));
    AppCompatCheckBox cb = viewHolder.getView(R.id.cb_select_apps);
    cb.setOnCheckedChangeListener(null); // CheckBox在執行setChecked時會觸發setOnCheckedChangeListener
    cb.setChecked(mDisablePackages.contains(info.getAppPackageName()));
    cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (mCheckedChangeListener != null) {
                mCheckedChangeListener.onCheckedChanged(info, position, isChecked);
            }
        }
    });
}
 
開發者ID:XYScience,項目名稱:StopApp,代碼行數:26,代碼來源:AppListAdapter.java

示例4: setupCheckbox

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
/**
 * Setups checkbox in menu.
 * @param menu menu
 */
private void setupCheckbox(Menu menu)
{
	AppCompatCheckBox checkBox = (AppCompatCheckBox) menu.findItem(R.id.equalizer_lock).getActionView();
	ColorStateList colorStateList = new ColorStateList(new int[][]{
			new int[]{-android.R.attr.state_enabled}, // disabled
			new int[]{android.R.attr.state_enabled}, // enabled
	},
			new int[]{
					Color.WHITE, // disabled
					Color.WHITE // enabled
			});
	checkBox.setSupportButtonTintList(colorStateList);
	checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
		@Override
		public void onCheckedChanged(CompoundButton compoundButton, boolean b)
		{
			lockedSliders = b;
		}
	});
	checkBox.setText(getString(R.string.lock_sliders));
	checkBox.setChecked(true);
	checkBox.setPadding(0,0,Math.round(getResources().getDimension(R.dimen.activity_horizontal_margin)),0);
}
 
開發者ID:JiriSko,項目名稱:amixer-webui-android,代碼行數:28,代碼來源:EqualizerActivity.java

示例5: setFilters

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
public void setFilters(@Nullable List<SearchFilter> filters) {
    mSearchFilters = filters;
    mFlexboxLayout.removeAllViews();
    if (filters == null) {
        mSearchFiltersStates = null;
        mFlexboxLayout.setVisibility(View.GONE);
    } else {
        mSearchFiltersStates = new ArrayList<>();
        for (SearchFilter filter : filters) {
            AppCompatCheckBox checkBox = new AppCompatCheckBox(mContext);
            checkBox.setText(filter.getTitle());
            checkBox.setTextSize(12);
            checkBox.setTextColor(mTextColor);
            checkBox.setChecked(filter.isChecked());

            FlexboxLayout.LayoutParams lp = new FlexboxLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            lp.setMargins(getResources().getDimensionPixelSize(R.dimen.search_filter_margin_start), getResources().getDimensionPixelSize(R.dimen.search_filter_margin_top), getResources().getDimensionPixelSize(R.dimen.search_filter_margin_top), getResources().getDimensionPixelSize(R.dimen.search_filter_margin_top));

            checkBox.setLayoutParams(lp);
            checkBox.setTag(filter.getTagId());
            mFlexboxLayout.addView(checkBox);
            mSearchFiltersStates.add(filter.isChecked());
        }
    }
}
 
開發者ID:lapism,項目名稱:SearchBar-SearchView,代碼行數:26,代碼來源:SearchView.java

示例6: onClick

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
@Override
public void onClick(View view) {
    if (mConfiguration.getMaxSize() == mMediaActivity.getCheckedList().size() &&
            !mMediaActivity.getCheckedList().contains(mediaBean)) {
        AppCompatCheckBox checkBox = (AppCompatCheckBox) view;
        checkBox.setChecked(false);
        Logger.i("=>" + mMediaActivity.getResources().getString(R.string.gallery_image_max_size_tip, mConfiguration.getMaxSize()));
    } else {
        RxBus.getDefault().post(new MediaCheckChangeEvent(mediaBean));
    }
}
 
開發者ID:Loofer,項目名稱:Watermark,代碼行數:12,代碼來源:MediaGridAdapter.java

示例7: addMultipleChoice

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
public void addMultipleChoice(String text, boolean checked, final OnCheckListener listener) {
    ColorStateList colorStateList = new ColorStateList(
            new int[][]{
                    new int[]{-android.R.attr.state_enabled}, //disabled
                    new int[]{android.R.attr.state_enabled}, //enabled
                    new int[]{android.R.attr.state_checked}
            },
            new int[]{
                    R.color.checkbox_disabled_color, //disabled
                    R.color.checkbox_enabled_color, //enabled
                    R.color.checkbox_checked_color
            }
    );

    AppCompatCheckBox box = new AppCompatCheckBox(getContext());
    box.setChecked(checked);
    box.setSupportButtonTintList(colorStateList);
    box.setText(localize(text));
    box.setTextColor(getResources().getColor(R.color.text_dark));
    box.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            listener.onCheck(isChecked);
        }
    });
    mCheckBoxes.addView(box);
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-android,代碼行數:28,代碼來源:ChoiceView.java

示例8: onCheckboxTitleSubtitleClick

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
@Override
public void onCheckboxTitleSubtitleClick(View view, TitleSubtitleCheckboxData data, int position) {
    boolean oldValue = data.isEnabled();
    boolean newValue = !oldValue;

    data.setEnabled(newValue);

    AppCompatCheckBox checkBox = view.findViewById(R.id.checkbox);
    checkBox.setChecked(newValue);

    Snackbar.make(coordinatorLayout, "Toggled position: " + position, Snackbar.LENGTH_SHORT).show();
}
 
開發者ID:UdiOshi85,項目名稱:GenericSettings,代碼行數:13,代碼來源:CheckableTypesPresenter.java

示例9: onTitleSubtitleExtraCheckboxClick

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
@Override
public void onTitleSubtitleExtraCheckboxClick(View view, TitleSubtitleExtraCheckboxData data, int position) {
    boolean oldValue = data.isEnabled();
    boolean newValue = !oldValue;

    data.setEnabled(newValue);

    AppCompatCheckBox checkBox = view.findViewById(R.id.checkbox);
    checkBox.setChecked(newValue);

    Snackbar.make(coordinatorLayout, "Toggled position: " + position, Snackbar.LENGTH_SHORT).show();
}
 
開發者ID:UdiOshi85,項目名稱:GenericSettings,代碼行數:13,代碼來源:CheckableTypesPresenter.java

示例10: initViewDefault

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
private View initViewDefault(LayoutInflater inflater, ViewGroup parent) {
    RadioGroup radioGroup = new RadioGroup(inflater.getContext());
    radioGroup.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
    radioGroup.setDividerDrawable(ContextCompat.getDrawable(parent.getContext(),
            R.drawable.rsb_divider_empty_8dp));

    for (int i = 0; i < choices.length; i++) {
        Choice<T> item = choices[i];

        // Create & add the View to our body-view
        AppCompatCheckBox checkBox = (AppCompatCheckBox) inflater.inflate(R.layout.rsb_item_checkbox,
                radioGroup,
                false);
        checkBox.setText(item.getText());
        checkBox.setId(i);
        radioGroup.addView(checkBox);

        // Set initial state
        if (currentSelected.contains(item.getValue())) {
            checkBox.setChecked(true);
        }

        // Update result when value changes
        checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {

            if (isChecked) {
                currentSelected.add(item.getValue());
            } else {
                currentSelected.remove(item.getValue());
            }
        });
    }

    return radioGroup;
}
 
開發者ID:ResearchStack,項目名稱:ResearchStack,代碼行數:36,代碼來源:MultiChoiceQuestionBody.java

示例11: initLoginDialogViews

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
private void initLoginDialogViews(View loginDialogView) {

        usernameEditText = (AppCompatEditText) loginDialogView.findViewById(R.id.edit_text_dialog_ftp_username);
        passwordEditText = (AppCompatEditText) loginDialogView.findViewById(R.id.edit_text_dialog_ftp_password);
        usernameTextInput = (TextInputLayout) loginDialogView.findViewById(R.id.text_input_dialog_ftp_username);
        passwordTextInput = (TextInputLayout) loginDialogView.findViewById(R.id.text_input_dialog_ftp_password);
        mAnonymousCheckBox = (AppCompatCheckBox) loginDialogView.findViewById(R.id.checkbox_ftp_anonymous);
        mSecureCheckBox = (AppCompatCheckBox) loginDialogView.findViewById(R.id.checkbox_ftp_secure);

        mAnonymousCheckBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
            if (isChecked) {
                usernameEditText.setEnabled(false);
                passwordEditText.setEnabled(false);
            } else {
                usernameEditText.setEnabled(true);
                passwordEditText.setEnabled(true);
            }
        });

        // init dialog views as per preferences
        if (getUsernameFromPreferences().equals(FTPService.DEFAULT_USERNAME)) {
            mAnonymousCheckBox.setChecked(true);
        } else {

            usernameEditText.setText(getUsernameFromPreferences());
            passwordEditText.setText(getPasswordFromPreferences());
        }

        if (getSecurePreference()) {
            mSecureCheckBox.setChecked(true);
        } else mSecureCheckBox.setChecked(false);

        // check if we have a keystore
        InputStream stream = getResources().openRawResource(R.raw.key);
        if (stream == null) {
            mSecureCheckBox.setEnabled(false);
            mSecureCheckBox.setChecked(false);
            setSecurePreference(false);
        }
    }
 
開發者ID:TeamAmaze,項目名稱:AmazeFileManager,代碼行數:41,代碼來源:FTPServerFragment.java

示例12: onCreateDialog

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();

    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = getActivity().getLayoutInflater();

    final View view = dialogInflater.inflate(R.layout.dialog_create_connection, null, false);
    name = (AppCompatEditText) view.findViewById(R.id.name);
    host = (AppCompatEditText) view.findViewById(R.id.host);
    port = (AppCompatEditText) view.findViewById(R.id.port);
    path = (AppCompatEditText) view.findViewById(R.id.path);
    hostContainer = view.findViewById(R.id.hostContainer);
    pathContainer = view.findViewById(R.id.pathContainer);
    username = (AppCompatEditText) view.findViewById(R.id.username);
    usernameContainer = view.findViewById(R.id.usernameContainer);
    password = (AppCompatEditText) view.findViewById(R.id.password);
    passwordContainer = view.findViewById(R.id.passwordContainer);
    scheme = (AppCompatSpinner) view.findViewById(R.id.scheme);
    anonymous = (AppCompatCheckBox) view.findViewById(R.id.anonymous);
    anonymous.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            usernameContainer.setVisibility(b ? View.GONE : View.VISIBLE);
            passwordContainer.setVisibility(b ? View.GONE : View.VISIBLE);
        }
    });

    if(connection_id != 0){
        NetworkConnection connection =
                NetworkConnection.fromConnectionId(getActivity(), connection_id);

        ArrayAdapter myAdap = (ArrayAdapter) scheme.getAdapter();
        int spinnerPosition = myAdap.getPosition(connection.getScheme().toUpperCase());
        scheme.setSelection(spinnerPosition);

        name.setText(connection.getName());
        host.setText(connection.getHost());
        port.setText(Integer.toString(connection.getPort()));
        path.setText(connection.getPath());
        username.setText(connection.getUserName());
        password.setText(connection.getPassword());
        anonymous.setChecked(connection.isAnonymousLogin());
        if(SERVER.equals(connection.getType())){
            hostContainer.setVisibility(View.GONE);
            pathContainer.setVisibility(View.VISIBLE);
        }
    }
    builder.setTitle( (connection_id == 0 ? "New" : "Edit") + " Connection");
    builder.setView(view);

    builder.setPositiveButton(connection_id == 0 ? "ADD" : "SAVE", new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final BaseActivity activity = (BaseActivity) getActivity();

            NetworkConnection networkConnection = getNetworkConnection();
            if(validate(networkConnection)){
                new CreateConnectionTask(activity, networkConnection).executeOnExecutor(
                        ProviderExecutor.forAuthority(ExplorerProvider.AUTHORITY));
            }

        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);

    return builder.create();
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:69,代碼來源:CreateConnectionFragment.java

示例13: checkReversed

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
public void checkReversed(AppCompatCheckBox checkBox, Selectable selectable)
{
	selectable.setSelectableSelected(!selectable.isSelectableSelected());
	checkBox.setChecked(selectable.isSelectableSelected());
}
 
開發者ID:genonbeta,項目名稱:TrebleShot,代碼行數:6,代碼來源:SelectedEditorDialog.java

示例14: showCheckedIcons

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
public void showCheckedIcons(AppCompatCheckBox cb)
{
    mIsShowCheckedIcons = true;
    cb.setChecked(true);
    notifyDataSetChanged();
}
 
開發者ID:lynnchurch,項目名稱:SwipeRefreshPlusLayout,代碼行數:7,代碼來源:CheckedAdapter.java

示例15: onCreate

import android.support.v7.widget.AppCompatCheckBox; //導入方法依賴的package包/類
@Override
final protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gitty_reporter_layout);

    // Get Device info and print them in EditText
    deviceInfoEditText = (EditText) findViewById(R.id.gittyreporter_device_info);
    getDeviceInfo();
    deviceInfoEditText.setText(deviceInfo);

    init(savedInstanceState);

    final View nextFab = findViewById(R.id.gittyreporter_fab_next);
    final View sendFab = findViewById(R.id.gittyreporter_fab_send);

    if (!enableGitHubLogin){
        nextFab.setVisibility(View.INVISIBLE);
        sendFab.setVisibility(View.VISIBLE);
    }

    AppCompatCheckBox githubCheckbox = (AppCompatCheckBox) findViewById(R.id.gittyreporter_github_checkbox);
    AppCompatButton registerButton = (AppCompatButton) findViewById(R.id.gittyreporter_github_register);

    final EditText userName = (EditText) findViewById(R.id.gittyreporter_login_username);
    final EditText userPassword = (EditText) findViewById(R.id.gittyreporter_login_password);

    userPassword.setTypeface(Typeface.DEFAULT);
    userPassword.setTransformationMethod(new PasswordTransformationMethod());

    if (!enableGuestGitHubLogin){
        githubCheckbox.setChecked(false);
        githubCheckbox.setVisibility(View.GONE);
        registerButton.setVisibility(View.VISIBLE);
    }

    githubCheckbox.setOnCheckedChangeListener(
            new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (isChecked){
                        userName.setEnabled(false);
                        userName.setText("");
                        userPassword.setEnabled(false);
                        userPassword.setText("");
                    } else {
                        userName.setEnabled(true);
                        userPassword.setEnabled(true);
                    }
                }
            }
    );
}
 
開發者ID:paolorotolo,項目名稱:GittyReporter,代碼行數:53,代碼來源:GittyReporter.java


注:本文中的android.support.v7.widget.AppCompatCheckBox.setChecked方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。