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


Java CompoundButton.OnCheckedChangeListener方法代碼示例

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


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

示例1: 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

示例2: addEvent

import android.widget.CompoundButton; //導入方法依賴的package包/類
@Override
public void addEvent(String type) {
  super.addEvent(type);
  if (type != null && type.equals(Constants.Event.CHANGE) && getHostView() != null) {
    if (mListener == null) {
      mListener = new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
          Map<String, Object> params = new HashMap<>(2);
          params.put("value", isChecked);

          Map<String, Object> domChanges = new HashMap<>();
          Map<String, Object> attrsChanges = new HashMap<>();
          attrsChanges.put("checked",Boolean.toString(isChecked));
          domChanges.put("attrs",attrsChanges);
          fireEvent(Constants.Event.CHANGE, params,domChanges);
        }
      };
    }
    getHostView().setOnCheckedChangeListener(mListener);
  }
}
 
開發者ID:weexext,項目名稱:ucar-weex-core,代碼行數:23,代碼來源:WXSwitch.java

示例3: onCreate

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

    final Switch readClipboard = findViewById(R.id.read_clipboard);
    final Switch autoCopy = findViewById(R.id.auto_copy);

    final SharedPreferences preferences = getSharedPreferences("data", MODE_PRIVATE);

    readClipboard.setChecked(preferences.getBoolean("read_clipboard", true));
    autoCopy.setChecked(preferences.getBoolean("auto_copy", true));

    CompoundButton.OnCheckedChangeListener listener = new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            preferences.edit()
                    .putBoolean("read_clipboard", readClipboard.isChecked())
                    .putBoolean("auto_copy", autoCopy.isChecked())
                    .apply();
        }
    };

    readClipboard.setOnCheckedChangeListener(listener);
    autoCopy.setOnCheckedChangeListener(listener);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT_WATCH) {
        readClipboard.setCursorVisible(false);
    }

}
 
開發者ID:Sea-n,項目名稱:gitio,代碼行數:32,代碼來源:SettingActivity.java

示例4: ListBean

import android.widget.CompoundButton; //導入方法依賴的package包/類
public ListBean(int mItemType, String mImageUrl, String mText, String mValue, int mId, LatteDelegate mDelegate, CompoundButton.OnCheckedChangeListener mOnCheckedChangeListener) {
    this.mItemType = mItemType;
    this.mImageUrl = mImageUrl;
    this.mText = mText;
    this.mValue = mValue;
    this.mId = mId;
    this.mDelegate = mDelegate;
    this.mOnCheckedChangeListener = mOnCheckedChangeListener;
}
 
開發者ID:remerber,項目名稱:FastEc,代碼行數:10,代碼來源:ListBean.java

示例5: newInstance

import android.widget.CompoundButton; //導入方法依賴的package包/類
public static SwitcherFragment newInstance(String title, String summary, boolean checked,
                                           CompoundButton.OnCheckedChangeListener onCheckedChangeListener) {
    SwitcherFragment fragment = new SwitcherFragment();
    fragment.mTitle = title;
    fragment.mSummary = summary;
    fragment.mChecked = checked;
    fragment.mOnCheckedChangeListener = onCheckedChangeListener;
    return fragment;
}
 
開發者ID:AyushR1,項目名稱:KernelAdiutor-Mod,代碼行數:10,代碼來源:SwitcherFragment.java

示例6: setOnCheckedChangeListener

import android.widget.CompoundButton; //導入方法依賴的package包/類
public void setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener listener) {
	mSwitch.setOnCheckedChangeListener(listener);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:CheckableMenuItem.java

示例7: setOnCheckedChangeListener

import android.widget.CompoundButton; //導入方法依賴的package包/類
@Override
public MartianViewHolder setOnCheckedChangeListener(int viewId, CompoundButton.OnCheckedChangeListener listener) {
    CompoundButton view = getView(viewId);
    view.setOnCheckedChangeListener(listener);
    return this;
}
 
開發者ID:vsona,項目名稱:RxJava2RetrofitDemo,代碼行數:7,代碼來源:MartianViewHolder.java

示例8: onCreate

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

    s = (Switch) findViewById(R.id.active);
    tp = (TimePicker) findViewById(R.id.lockTime);
    tp2 = (TimePicker) findViewById(R.id.unlockTime);


    database = FirebaseDatabase.getInstance();
    lightSettingsRef = database.getReference("lightsettings");
    lightSettingsRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Log.e("db", "dbok in lightsettings.java");
            tp.setOnTimeChangedListener(null);
            tp2.setOnTimeChangedListener(null);
            s.setOnCheckedChangeListener(null);

            tp.setCurrentHour(((Number) dataSnapshot.child("onH").getValue()).intValue());
            tp.setCurrentMinute(((Number) dataSnapshot.child("onM").getValue()).intValue());
            tp2.setCurrentHour(((Number) dataSnapshot.child("offH").getValue()).intValue());
            tp2.setCurrentMinute(((Number) dataSnapshot.child("offM").getValue()).intValue());
            s.setChecked((boolean) dataSnapshot.child("active").getValue());


            tp.setOnTimeChangedListener(timePickerListener);
            tp2.setOnTimeChangedListener(timePickerListener);
            s.setOnCheckedChangeListener(switchListener);


        }
        @Override
        public void onCancelled(DatabaseError databaseError) {
            Log.e("db",databaseError.toString());

        }
    });

    timePickerListener = new TimePicker.OnTimeChangedListener(){
        @Override
        public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
            Log.d("deb","activity.updatesettings");

            lightSettingsRef.setValue(new LightSettingsHelper(
                    s.isChecked(),
                    tp.getCurrentHour(),
                    tp.getCurrentMinute(),
                    tp2.getCurrentHour(),
                    tp2.getCurrentMinute()
            ));
        }

    };

    switchListener = new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            lightSettingsRef.setValue(new LightSettingsHelper(
                    s.isChecked(),
                    tp.getCurrentHour(),
                    tp.getCurrentMinute(),
                    tp2.getCurrentHour(),
                    tp2.getCurrentMinute()
            ));
        }
    };

    tp.setOnTimeChangedListener(timePickerListener);
    tp2.setOnTimeChangedListener(timePickerListener);
    s.setOnCheckedChangeListener(switchListener);

}
 
開發者ID:reevejd,項目名稱:SmartHome,代碼行數:75,代碼來源:LightSettingsActivity.java

示例9: setOnCheckedChangeListener

import android.widget.CompoundButton; //導入方法依賴的package包/類
public void setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener listener){
    mSwitch.setOnCheckedChangeListener(listener);
}
 
開發者ID:teisun,項目名稱:SunmiUI,代碼行數:4,代碼來源:ButtonSwitch.java

示例10: setOnCheckedChangeListener

import android.widget.CompoundButton; //導入方法依賴的package包/類
/**
 * Sets the on checked change listener of the iView.
 */
IViewHolder setOnCheckedChangeListener(int viewId, CompoundButton.OnCheckedChangeListener listener);
 
開發者ID:vsona,項目名稱:RxJava2RetrofitDemo,代碼行數:5,代碼來源:IViewHolder.java

示例11: setOnCheckedChangeListener

import android.widget.CompoundButton; //導入方法依賴的package包/類
/**
 * Sets the on checked change listener of the view.
 *
 * @param viewId   The view id.
 * @param listener The checked change listener of compound button.
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnCheckedChangeListener(int viewId, CompoundButton.OnCheckedChangeListener listener) {
    CompoundButton view = getView(viewId);
    view.setOnCheckedChangeListener(listener);
    return this;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:BaseViewHolder.java

示例12: setOnCheckedChangeListener

import android.widget.CompoundButton; //導入方法依賴的package包/類
/**
 * Sets the on checked change listener of the view.
 *
 * @param viewId   The view id.
 * @param listener The checked change listener of compound button.
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnCheckedChangeListener(@IdRes int viewId, CompoundButton.OnCheckedChangeListener listener) {
    CompoundButton view = getView(viewId);
    view.setOnCheckedChangeListener(listener);
    return this;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:BaseViewHolder.java

示例13: onToggle

import android.widget.CompoundButton; //導入方法依賴的package包/類
/**
 * @return function which assigns {@link android.widget.CompoundButton.OnCheckedChangeListener}
 * to {@link CompoundButton}.
 * @throws ClassCastException if current view is not a {@link CompoundButton}.
 */
public static BindingFunction onToggle(@Nullable CompoundButton.OnCheckedChangeListener listener) {
    return view -> ((CompoundButton) view).setOnCheckedChangeListener(listener);
}
 
開發者ID:dmitry-zaitsev,項目名稱:BlueTape,代碼行數:9,代碼來源:BlueTapeDsl.java


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