本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
});
}
示例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);
}
示例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());
}
}
}
示例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));
}
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}
示例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);
}
}
示例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();
}
示例13: checkReversed
import android.support.v7.widget.AppCompatCheckBox; //导入方法依赖的package包/类
public void checkReversed(AppCompatCheckBox checkBox, Selectable selectable)
{
selectable.setSelectableSelected(!selectable.isSelectableSelected());
checkBox.setChecked(selectable.isSelectableSelected());
}
示例14: showCheckedIcons
import android.support.v7.widget.AppCompatCheckBox; //导入方法依赖的package包/类
public void showCheckedIcons(AppCompatCheckBox cb)
{
mIsShowCheckedIcons = true;
cb.setChecked(true);
notifyDataSetChanged();
}
示例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);
}
}
}
);
}