本文整理汇总了Java中android.widget.CompoundButton类的典型用法代码示例。如果您正苦于以下问题:Java CompoundButton类的具体用法?Java CompoundButton怎么用?Java CompoundButton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompoundButton类属于android.widget包,在下文中一共展示了CompoundButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.widget.CompoundButton; //导入依赖的package包/类
public void init() {
recyclerView = (RecyclerView) findViewById(R.id.student_recyclerview);
btnSearch = (ToggleButton)findViewById(R.id.btn_search_student);
btnSearchOk = (Button)findViewById(R.id.btn_search_ok_student);
btnBack = (Button) findViewById(R.id.btn_back_student);
editTextSearch =(EditText)findViewById(R.id.etxt_search_student);
frameLayoutSearch = (FrameLayout)findViewById(R.id.frame_search_student);
txtMsgContent = (TextView) findViewById(R.id.message_label_stud);
frameLayoutSearch.setVisibility(View.GONE);
txtMsgContent.setVisibility(View.INVISIBLE);
btnSearch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked)
frameLayoutSearch.setVisibility(View.VISIBLE);
else
frameLayoutSearch.setVisibility(View.GONE);
}
});
}
示例2: onCreateView
import android.widget.CompoundButton; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_select_distinct, container, false);
((CreateGroupChannelActivity) getActivity()).setState(CreateGroupChannelActivity.STATE_SELECT_DISTINCT);
mListener = (CreateGroupChannelActivity) getActivity();
mCheckBox = (CheckBox) rootView.findViewById(R.id.checkbox_select_distinct);
mCheckBox.setChecked(true);
mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mListener.onDistinctSelected(isChecked);
}
});
return rootView;
}
示例3: onCheckedChanged
import android.widget.CompoundButton; //导入依赖的package包/类
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// prevents from infinite recursion
if (mProtectFromCheckedChange) {
return;
}
mProtectFromCheckedChange = true;
if (mCheckedId != -1) {
setCheckedStateForView(mCheckedId, false);
}
mProtectFromCheckedChange = false;
int id = buttonView.getId();
setCheckedId(id);
}
示例4: onCheckedChanged
import android.widget.CompoundButton; //导入依赖的package包/类
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int id = buttonView.getId();
if (id == R.id.cb_origin) {
if (isChecked) {
long size = 0;
for (ImageItem item : selectedImages)
size += item.size;
String fileSize = Formatter.formatFileSize(this, size);
isOrigin = true;
mCbOrigin.setText(getString(R.string.origin_size, fileSize));
} else {
isOrigin = false;
mCbOrigin.setText(getString(R.string.origin));
}
}
}
示例5: onCheckedChanged
import android.widget.CompoundButton; //导入依赖的package包/类
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(buttonView==mToggleButton) {
if(isChecked){
mLastLeftSpeed=0;
mLastRightSpeed = 0;
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_UI);
mSensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_UI);
}
else{
mSensorManager.unregisterListener(this);
setSpeed(0,0);
}
}
}
示例6: onCheckedChanged
import android.widget.CompoundButton; //导入依赖的package包/类
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
mType = b ? MOVIES : TV_SHOWS;
int textColorLight = ContextCompat.getColor(getActivity(), R.color.colorPrimary);
int textColorDark = ContextCompat.getColor(getActivity(), R.color.colorGray);
moviesRadioButton.setTextColor(b ? textColorLight : textColorDark);
tvRadioButton.setTextColor(!b ? textColorLight : textColorDark);
}
示例7: unSelector
import android.widget.CompoundButton; //导入依赖的package包/类
public void unSelector(int position, @NonNull RRecyclerView recyclerView, @NonNull String viewTag) {
boolean notify = false;
removeSelectorPosition(position);
RBaseViewHolder vh = (RBaseViewHolder) recyclerView.findViewHolderForAdapterPosition(position);
if (vh != null) {
final View view = vh.tag(viewTag);
if (view != null) {
if (view instanceof CompoundButton) {
checkedButton((CompoundButton) view, false);
} else if (view instanceof RCheckGroup.ICheckView) {
((RCheckGroup.ICheckView) view).setChecked(false);
}
notify = true;
}
} else {
notifyItemChanged(position);
}
if (notify) {
//防止在视图还没有加载的时候,通知事件
notifySelectorChange();
}
}
示例8: RadiusViewDelegate
import android.widget.CompoundButton; //导入依赖的package包/类
public RadiusViewDelegate(View view, Context context, AttributeSet attrs) {
this.view = view;
this.mContext = context;
obtainAttributes(context, attrs);
view.setSelected(selected);
if (!(view instanceof CompoundButton) && !view.isClickable()) {
view.setClickable(isRippleEnable);
}
}
示例9: init
import android.widget.CompoundButton; //导入依赖的package包/类
private void init() {
sunStrikeResources = new SunStrikeResources(getContext());
setBackgroundColor(sunStrikeResources.getColorTransparent());
setCustomColor(sunStrikeResources.getColorBackground(),
sunStrikeResources.getColorProgress(),
sunStrikeResources.getColorChecked());
this.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (callbackList.size() != 0) {
for (Callback callback : callbackList) {
if (isChecked) {
callback.onChecked();
} else {
callback.onUnchecked();
}
}
}
}
});
}
示例10: beautyView
import android.widget.CompoundButton; //导入依赖的package包/类
private void beautyView() {
beautyEditText(this.mInputAccount, L10NString.getString("umgr_please_input_username"), this.mAccountTextWatcher);
beautyCleanButton(this.mClearInputAccount, this);
this.mInputAccountLayout.setOnClickListener(this);
beautyCleanButton(this.mClearInputPassword, this);
this.mInputPassword.setOnClickListener(this);
beautyEditText(this.mInputPassword, L10NString.getString("umgr_please_input_password"), this.mPasswordTextWatcher);
beautyColorTextView(this.mRegister, "#007dc4", false, L10NString.getString("umgr_whether_register_ornot"), this);
beautyColorTextView(this.mFindpwd, "#007dc4", false, L10NString.getString("umgr_whether_forget_password"), this);
beautyColorTextView(this.mSwitchAccount, "#007dc4", false, L10NString.getString("umgr_third_login_qihoo_tip"), this);
beautyButtonGreen(this.mLogin, L10NString.getString("umgr_login"), this);
beautyTextView(this.mAgreeClause1, L10NString.getString("umgr_login_agree_clause_1"));
beautyTextView(this.mAgreeClauseUser, L10NString.getString("umgr_agree_clause_2_user"));
beautyColorTextView(this.mAgreement, "#0099e5", true, L10NString.getString("umgr_agree_clause_2_agreement"), this);
beautyTextView(this.mAnd, L10NString.getString("umgr_agree_clause_2_and"));
beautyColorTextView(this.mPrivacy, "#0099e5", true, L10NString.getString("umgr_agree_clause_2_privacy"), this);
beautyCheckButton(this.mShowPwd, new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
LoginActivity.this.mInputPassword.setTransformationMethod(LoginActivity.this.mShowPwd.isChecked() ? HideReturnsTransformationMethod.getInstance() : PasswordTransformationMethod.getInstance());
}
});
loadPrivateConfig();
}
示例11: checkedButton
import android.widget.CompoundButton; //导入依赖的package包/类
public static void checkedButton(CompoundButton compoundButton, boolean checked) {
if (compoundButton == null) {
return;
}
if (compoundButton.isChecked() == checked) {
return;
}
CompoundButton.OnCheckedChangeListener onCheckedChangeListener =
(CompoundButton.OnCheckedChangeListener) Reflect.getMember(CompoundButton.class,
compoundButton, "mOnCheckedChangeListener");
compoundButton.setOnCheckedChangeListener(null);
compoundButton.setChecked(checked);
compoundButton.setOnCheckedChangeListener(onCheckedChangeListener);
}
示例12: init
import android.widget.CompoundButton; //导入依赖的package包/类
/**
* 속성 초기화, 클릭 이벤트 설정
*/
private void init(Context context, int textSize) {
setBackground(ContextCompat.getDrawable(context, R.drawable.dmstb));
mNormalTextColor = ContextCompat.getColor(context, R.color.colorPrimary);
mCheckedTextColor = ContextCompat.getColor(context, android.R.color.white);
setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked()) {
setTextColor(mCheckedTextColor);
} else {
setTextColor(mNormalTextColor);
}
}
});
setTextSize(TypedValue.COMPLEX_UNIT_SP, DensityConverter.pxTodp(context, textSize));
setTextColor(mNormalTextColor);
setMinWidth(0);
setMinimumWidth(0);
setMinHeight(0);
setMinimumHeight(0);
}
示例13: customizeCheckbox
import android.widget.CompoundButton; //导入依赖的package包/类
/**
* Checkbox - Used to customize checkbox properties
* For additional information please see:
* https://developer.android.com/guide/topics/ui/controls/checkbox.html
*/
private void customizeCheckbox() {
//Set the checkbox to a specific checked state
checkBox.setChecked(true);
//Set the label for the checkbox
checkBox.setText("My Checkbox");
//Set a checked state change listener
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
Toast.makeText(getApplicationContext(),
"Checkbox state changed!", Toast.LENGTH_SHORT).show();
}
});
}
示例14: onCheckedChanged
import android.widget.CompoundButton; //导入依赖的package包/类
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) {
case R.id.sw_discu_top:
if (isChecked) {
OperationRong.setConversationTop(mContext, Conversation.ConversationType.DISCUSSION, targetId, true);
} else {
OperationRong.setConversationTop(mContext, Conversation.ConversationType.DISCUSSION, targetId, false);
}
break;
case R.id.sw_discu_notfaction:
if (isChecked) {
OperationRong.setConverstionNotif(mContext, Conversation.ConversationType.DISCUSSION, targetId, true);
} else {
OperationRong.setConverstionNotif(mContext, Conversation.ConversationType.DISCUSSION, targetId, false);
}
break;
}
}
示例15: onCheckedChanged
import android.widget.CompoundButton; //导入依赖的package包/类
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
switch(compoundButton.getId()){
case R.id.activity_rant_checkbox_up:
mDownCheckbox.setClickable(false);
mUpCheckbox.setClickable(true);
postThumb(1, mDetailItem.getRantId());
break;
case R.id.activity_rant_checkbox_down:
mDownCheckbox.setClickable(true);
mUpCheckbox.setClickable(false);
postThumb(-1, mDetailItem.getRantId());
break;
}
}