本文整理汇总了Java中android.widget.CompoundButton.setOnCheckedChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java CompoundButton.setOnCheckedChangeListener方法的具体用法?Java CompoundButton.setOnCheckedChangeListener怎么用?Java CompoundButton.setOnCheckedChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.CompoundButton
的用法示例。
在下文中一共展示了CompoundButton.setOnCheckedChangeListener方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChildViewAdded
import android.widget.CompoundButton; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void onChildViewAdded(View parent, View child) {
if (parent == NestRadioGroup.this) {
final List<CompoundButton> list = findCheckedView(child);
for(CompoundButton view : list){
if (view != null) {
int id = view.getId();
// generates an id if it's missing
if (id == View.NO_ID && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
id = View.generateViewId();
view.setId(id);
}
view.setOnCheckedChangeListener(mChildOnCheckedChangeListener);
}
}
}
if (mOnHierarchyChangeListener != null) {
mOnHierarchyChangeListener.onChildViewAdded(parent, child);
}
}
示例2: 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);
}
示例3: onCreate
import android.widget.CompoundButton; //导入方法依赖的package包/类
protected void onCreate(Bundle bundle)
{
super.onCreate(bundle);
setContentView(R.layout.jni_main);
StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary));
ViewWindow.showView(this, "");
mCompoundButton = (CompoundButton) findViewById(R.id.sw_window);
mCompoundButton.setOnCheckedChangeListener(this);
if (getResources().getBoolean(R.bool.use_watching_service))
{
startService(new Intent(this, WatchingService.class));
}
}
示例4: bindEngineCheckboxesToMenu
import android.widget.CompoundButton; //导入方法依赖的package包/类
protected void bindEngineCheckboxesToMenu() {
for (int i = 0; i < searchEngineGroup.getChildCount(); i++) {
final CompoundButton engineButton = (CompoundButton) searchEngineGroup.getChildAt(i);
engineButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
((Activity) getContext()).invalidateOptionsMenu();
}
});
}
}
示例5: bindView
import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
public void bindView(View view, Context context, Cursor cursor) {
CompoundButton switchView = (CompoundButton) view.findViewById(R.id.repo_switch);
// Remove old listener (because we are reusing this view, we don't want
// to invoke the listener for the last repo to use it - particularly
// because we are potentially about to change the checked status
// which would in turn invoke this listener....
switchView.setOnCheckedChangeListener(null);
setupView(cursor, view, switchView);
}
示例6: mapClickEvents
import android.widget.CompoundButton; //导入方法依赖的package包/类
private void mapClickEvents(final int position, final T item, DataMapping<T> mapping, View root)
{
for (final ClickMapping<T> click : mapping.clickMappings) {
View clickView = findViewByIdPath(root, click.viewIdPath);
if (clickView instanceof CompoundButton) {
CompoundButton button = (CompoundButton)clickView;
button.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if (!mBlockClicks) {
click.listener.onViewChecked(position, item, isChecked);
}
}
});
}
else {
clickView.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View view)
{
if (!mBlockClicks) {
click.listener.onViewClicked(position, item);
}
}
});
}
}
}
示例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;
}
示例8: onCheck
import android.widget.CompoundButton; //导入方法依赖的package包/类
public CompoundButton onCheck(int id, OnCheckedChangeListener listener) {
CompoundButton checkable = (CompoundButton) find(id);
checkable.setOnCheckedChangeListener(listener);
return checkable;
}
示例9: setOnCheckedChangeListener
import android.widget.CompoundButton; //导入方法依赖的package包/类
/**
* CheckBox, RadioButton, Switch, SwitchCompat, ToggleButton
* ,AppCompatCheckBox, AppCompatRadioButton等都可以使用
* 凡是继承CompoundButton的都可以使用
*
* 最常使用的是CheckBox,RadioButton,SwitchCompat设置监听
*/
public SuperRecyclerHolder setOnCheckedChangeListener(@IdRes int viewId,
CompoundButton.OnCheckedChangeListener onCheckedChangeListener) {
CompoundButton checkBox = retrieveView(viewId);
checkBox.setOnCheckedChangeListener(onCheckedChangeListener);
return this;
}
示例10: 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;
}
示例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(@IdRes int viewId, CompoundButton.OnCheckedChangeListener listener) {
CompoundButton view = getView(viewId);
view.setOnCheckedChangeListener(listener);
return this;
}
示例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;
}