Java Code Examples for android.widget.Checkable#setChecked()

The following examples show how to use android.widget.Checkable#setChecked() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeViewAdapter.java    From TreeView with Apache License 2.0 6 votes vote down vote up
private void setupCheckableItem(View nodeView,
                                final TreeNode treeNode,
                                final CheckableNodeViewBinder viewBinder) {
    final View view = nodeView.findViewById(viewBinder.getCheckableViewId());

    if (view instanceof Checkable) {
        final Checkable checkableView = (Checkable) view;
        checkableView.setChecked(treeNode.isSelected());

        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean checked = checkableView.isChecked();
                selectNode(checked, treeNode);
                viewBinder.onNodeSelectedChanged(treeNode, checked);
            }
        });
    } else {
        throw new ClassCastException("The getCheckableViewId() " +
                "must return a CheckBox's id");
    }
}
 
Example 2
Source File: SwitchPreference.java    From MDPreference with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBindView(View view) {
    super.onBindView(view);
    Checkable checkable = (Checkable) view.findViewById(R.id.checkable);
    checkable.setChecked(isChecked());
    syncSummaryView();
}
 
Example 3
Source File: CheckableRelativeLayout.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
@Override
public void setChecked(boolean checked) {
	if (view == null) {
		view = findViewById(R.id.checkbox);
	}
	this.isChecked = checked;
	if (view instanceof Checkable) {
		Checkable checkable = (Checkable) view;
		checkable.setChecked(checked);
	}
}
 
Example 4
Source File: ViewHolder.java    From OpenEyes with Apache License 2.0 5 votes vote down vote up
/**
 * 设置是否选中
 * @param viewId
 * @param checked
 * @return
 */
public ViewHolder setChecked(int viewId, boolean checked)
{
    Checkable view = (Checkable) getView(viewId);
    view.setChecked(checked);
    return this;
}
 
Example 5
Source File: AbsMaterialCheckablePreference.java    From MaterialPreferences with Apache License 2.0 5 votes vote down vote up
@Override
protected void onViewCreated() {
    checkableWidget = (Checkable) findViewById(R.id.mp_checkable);
    boolean isChecked = getValue();
    checkableWidget.setChecked(isChecked);
    addPreferenceClickListener(this);
}
 
Example 6
Source File: ViewHolder.java    From Bailan with Apache License 2.0 4 votes vote down vote up
public ViewHolder setChecked(int viewId, boolean checked) {
    Checkable view = (Checkable) getView(viewId);
    view.setChecked(checked);
    return this;
}
 
Example 7
Source File: ViewHolder.java    From all-base-adapter with Apache License 2.0 4 votes vote down vote up
public ViewHolder setChecked(int viewId, boolean checked) {
    Checkable view = (Checkable) getView(viewId);
    view.setChecked(checked);
    return this;
}
 
Example 8
Source File: ViewHolder.java    From likequanmintv with Apache License 2.0 4 votes vote down vote up
public ViewHolder setChecked(int viewId, boolean checked)
{
    Checkable view = (Checkable) getView(viewId);
    view.setChecked(checked);
    return this;
}
 
Example 9
Source File: RecyclerViewHolder.java    From Android-BLE with Apache License 2.0 4 votes vote down vote up
public RecyclerViewHolder setChecked(int viewId, boolean checked) {
    Checkable view = (Checkable) getView(viewId);
    view.setChecked(checked);
    return this;
}
 
Example 10
Source File: XViewHolder.java    From XFrame with Apache License 2.0 4 votes vote down vote up
public XViewHolder setChecked(@IdRes int viewId, boolean checked) {
    Checkable view = (Checkable) getView(viewId);
    view.setChecked(checked);
    return this;
}
 
Example 11
Source File: RecyclerViewHolder.java    From StickyItemDecoration with Apache License 2.0 4 votes vote down vote up
public RecyclerViewHolder setChecked(int viewId, boolean checked) {
    Checkable view = (Checkable) findViewById(viewId);
    view.setChecked(checked);
    return this;
}
 
Example 12
Source File: ViewHolder.java    From MVVM-JueJin with MIT License 4 votes vote down vote up
public ViewHolder setChecked(int viewId, boolean checked) {
    Checkable view = (Checkable) getView(viewId);
    view.setChecked(checked);
    return this;
}
 
Example 13
Source File: SeekBarLinkedCheckBoxPreference.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
protected void onBindView(View view) {
    super.onBindView(view);
    mCheckable = (Checkable) view.findViewById(android.R.id.checkbox);
    mCheckable.setChecked(isChecked());
}
 
Example 14
Source File: BaseViewHolder.java    From fangzhuishushenqi with Apache License 2.0 4 votes vote down vote up
public BaseViewHolder setChecked(int viewId, boolean checked) {
    Checkable view = getView(viewId);
    view.setChecked(checked);
    return this;
}
 
Example 15
Source File: ViewHolder.java    From all-base-adapter with Apache License 2.0 4 votes vote down vote up
public ViewHolder setChecked(int viewId, boolean checked) {
    Checkable view = (Checkable) getView(viewId);
    view.setChecked(checked);
    return this;
}
 
Example 16
Source File: EasyLVHolder.java    From EasyAdapter with Apache License 2.0 4 votes vote down vote up
@Override
public EasyLVHolder setChecked(int viewId, boolean checked) {
    Checkable view = getView(viewId);
    view.setChecked(checked);
    return this;
}
 
Example 17
Source File: RecyclerViewHolder.java    From LLApp with Apache License 2.0 4 votes vote down vote up
public RecyclerViewHolder setChecked(int viewId, boolean checked) {
    Checkable view = (Checkable) getView(viewId);
    view.setChecked(checked);
    return this;
}
 
Example 18
Source File: ShareActivity.java    From Shaarlier with GNU General Public License v3.0 4 votes vote down vote up
private void updateToot(boolean toot) {
    Checkable tootCheck = findViewById(R.id.toot);
    tootCheck.setChecked(toot);
}
 
Example 19
Source File: BaseAdapterHelper.java    From BigApp_Discuz_Android with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the checked status of a checkable.
 *
 * @param viewId  The view id.
 * @param checked The checked status;
 * @return The BaseAdapterHelper for chaining.
 */
public BaseAdapterHelper setChecked(int viewId, boolean checked) {
    Checkable view = (Checkable) retrieveView(viewId);
    view.setChecked(checked);
    return this;
}
 
Example 20
Source File: BaseAdapterHelper.java    From base-adapter-helper-recyclerview with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the checked status of a checkable.
 *
 * @param viewId  The view id.
 * @param checked The checked status;
 * @return The BaseAdapterHelper for chaining.
 */
public BaseAdapterHelper setChecked(int viewId, boolean checked) {
    Checkable view = (Checkable) retrieveView(viewId);
    view.setChecked(checked);
    return this;
}