当前位置: 首页>>代码示例>>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;未经允许,请勿转载。