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


Java CompoundButton類代碼示例

本文整理匯總了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);
        }
    });
}
 
開發者ID:inteliedoit,項目名稱:thesis-project,代碼行數:22,代碼來源:StudentViewActivity.java

示例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;
}
 
開發者ID:narenkukreja,項目名稱:quire,代碼行數:21,代碼來源:SelectDistinctFragment.java

示例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);
}
 
開發者ID:mmb4rn0,項目名稱:RelativeRadioGroup,代碼行數:16,代碼來源:RelativeRadioGroup.java

示例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));
        }
    }
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:18,代碼來源:ImagePreviewActivity.java

示例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);
            }

        }
    }
 
開發者ID:zugaldia,項目名稱:android-robocar,代碼行數:18,代碼來源:TiltControllerActivity.java

示例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);
}
 
開發者ID:an-garcia,項目名稱:MovieGuide,代碼行數:9,代碼來源:DiscoverFragment.java

示例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();
    }
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:24,代碼來源:RModelAdapter.java

示例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);
    }
}
 
開發者ID:AriesHoo,項目名稱:UIWidget,代碼行數:10,代碼來源:RadiusViewDelegate.java

示例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();
                    }
                }
            }
        }
    });
}
 
開發者ID:AppliKey,項目名稱:Sunstrike,代碼行數:25,代碼來源:CustomSwitch.java

示例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();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:24,代碼來源:LoginActivity.java

示例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);
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:15,代碼來源:RModelAdapter.java

示例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);
}
 
開發者ID:DSM-DMS,項目名稱:DMS,代碼行數:27,代碼來源:DMSToggleButton.java

示例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();
        }
    });
}
 
開發者ID:corjohnson,項目名稱:IT405,代碼行數:22,代碼來源:MainActivity.java

示例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;
    }
}
 
開發者ID:zqHero,項目名稱:rongyunDemo,代碼行數:20,代碼來源:DiscussionDetailActivity.java

示例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;
    }

}
 
開發者ID:shawnsky,項目名稱:RantApp,代碼行數:17,代碼來源:RantActivity.java


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