Java Code Examples for android.widget.CheckBox#setLayoutParams()

The following examples show how to use android.widget.CheckBox#setLayoutParams() . 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: DebugDialogView.java    From VideoOS-Android-SDK with GNU General Public License v3.0 6 votes vote down vote up
private void initPreCheckBox() {
    mPreCheckoutBox = new CheckBox(mContext);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    mPreCheckoutBox.setText(openDebugTxt);
    mPreCheckoutBox.setLayoutParams(params);
    mPreCheckoutBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {
            if (isChecked && mDebugCheckBox.isChecked()) {
                mDebugCheckBox.setChecked(false);
            }
        }
    });
}
 
Example 2
Source File: PFCodeView.java    From PFLockScreen-Android with Apache License 2.0 6 votes vote down vote up
private void setUpCodeViews() {
    removeAllViews();
    mCodeViews.clear();
    mCode = "";
    for (int i = 0; i < mCodeLength; i++) {
        LayoutInflater inflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        CheckBox view = (CheckBox) inflater.inflate(R.layout.view_pf_code_checkbox, null);

        LinearLayout.LayoutParams layoutParams = new LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        int margin = getResources().getDimensionPixelSize(R.dimen.code_fp_margin);
        layoutParams.setMargins(margin, margin, margin, margin);
        view.setLayoutParams(layoutParams);
        view.setChecked(false);
        addView(view);
        mCodeViews.add(view);
    }
    if (mListener != null) {
        mListener.onCodeNotCompleted("");
    }
}
 
Example 3
Source File: MultiplePicker.java    From AndroidPicker with MIT License 6 votes vote down vote up
@NonNull
@Override
protected ScrollView makeCenterView() {
    ScrollView scrollView = new ScrollView(activity);
    layout = new LinearLayout(activity);
    layout.setOrientation(LinearLayout.VERTICAL);
    for (String item : items) {
        LinearLayout line = new LinearLayout(activity);
        line.setOrientation(LinearLayout.HORIZONTAL);
        line.setGravity(Gravity.CENTER);
        TextView textView = new TextView(activity);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, WRAP_CONTENT, 1.0f);
        lp.gravity = Gravity.CENTER;
        textView.setLayoutParams(lp);
        textView.setText(item);
        textView.setGravity(Gravity.CENTER);
        line.addView(textView);
        CheckBox checkBox = new CheckBox(activity);
        checkBox.setLayoutParams(new LinearLayout.LayoutParams(0, WRAP_CONTENT, 0.4f));
        line.addView(checkBox);
        layout.addView(line);
    }
    scrollView.addView(layout);
    return scrollView;
}
 
Example 4
Source File: EmailAutoCompleteLayout.java    From EmailAutoCompleteTextView with Apache License 2.0 6 votes vote down vote up
public EmailAutoCompleteLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    // Can't call through to super(Context, AttributeSet, int) since it doesn't exist on API 10
    super(context, attrs);

    backgroundPermissionManager = new BackgroundPermissionManager(this, context);

    setOrientation(LinearLayout.VERTICAL);
    setAddStatesFromChildren(true);

    final TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.EmailAutoCompleteLayout, defStyleAttr, defStyleRes);

    CharSequence permissionText = a.getText(R.styleable.EmailAutoCompleteLayout_permissionText);
    if (permissionText == null) {
        permissionText = context.getString(R.string.message_get_accounts_permission);
    }

    a.recycle();

    permissionPrimer = new CheckBox(context);
    permissionPrimer.setTextColor(0x8a000000);
    permissionPrimer.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    permissionPrimer.setText(permissionText);
    addView(permissionPrimer);
}
 
Example 5
Source File: UserSelectActivity.java    From WeChatMomentStat-Android with GNU General Public License v3.0 6 votes vote down vote up
protected void loadUserList() {
    LinearLayout userListContainer = (LinearLayout)findViewById(R.id.user_list_container);
    ArrayList<UserSnsInfo> userSnsList = Share.snsData.userSnsList;
    checkBoxList.clear();
    userListContainer.removeAllViews();
    for (int i=0;i<userSnsList.size();i++) {
        CheckBox userCheckBox = new CheckBox(this);
        userCheckBox.setText(userSnsList.get(i).userName + "(" + userSnsList.get(i).userId + ")" + "(" + String.format(getString(R.string.user_moment_count), userSnsList.get(i).snsList.size()) + ")");
        userListContainer.addView(userCheckBox);
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)userCheckBox.getLayoutParams();
        layoutParams.setMargins(5, 5, 5, 5);
        userCheckBox.setLayoutParams(layoutParams);
        userCheckBox.setChecked(true);
        userCheckBox.setTag(userSnsList.get(i).userId);
        checkBoxList.add(userCheckBox);
    }
}
 
Example 6
Source File: GBooleanView.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param context               the context to use.
 * @param attrs                 attributes.
 * @param parentView            parent
 * @param label                 label
 * @param value                 value
 * @param constraintDescription constraints
 * @param readonly              if <code>false</code>, the item is disabled for editing.
 */
public GBooleanView(Context context, AttributeSet attrs, LinearLayout parentView, String label, String value,
                    String constraintDescription, boolean readonly) {
    super(context, attrs);

    LinearLayout textLayout = new LinearLayout(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10, 10, 10, 10);
    textLayout.setLayoutParams(layoutParams);
    textLayout.setOrientation(LinearLayout.VERTICAL);
    parentView.addView(textLayout);

    TextView textView = new TextView(context);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    textView.setPadding(2, 2, 2, 2);
    textView.setText(label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription);
    textView.setTextColor(Compat.getColor(context, R.color.formcolor));

    textLayout.addView(textView);

    checkbox = new CheckBox(context);
    checkbox.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    checkbox.setPadding(15, 5, 15, 5);

    if (value != null) {
        if (value.trim().toLowerCase().equals("true")) { //$NON-NLS-1$
            checkbox.setChecked(true);
        } else {
            checkbox.setChecked(false);
        }
    }
    checkbox.setEnabled(!readonly);
    textLayout.addView(checkbox);
}
 
Example 7
Source File: UserSelectActivity.java    From hayoou-wechat-export with GNU General Public License v3.0 5 votes vote down vote up
protected void loadUserList() {
    LinearLayout userListContainer = (LinearLayout)findViewById(R.id.user_list_container);
    //ArrayList<UserSnsInfo> userSnsList = Share.snsData.userSnsList;
    checkBoxList.clear();
    userListContainer.removeAllViews();
    //userSnsList.get(i).snsList.size();
    ArrayList<UserSnsInfo> snsSizeRank = Share.snsData.userSnsList;//new ArrayList<UserSnsInfo>(userSnsList);
    Collections.sort(snsSizeRank, new Comparator<UserSnsInfo>() {
        @Override
        public int compare(UserSnsInfo lhs, UserSnsInfo rhs) {
            if (rhs.snsList.size() - lhs.snsList.size() > 0) {
                return 1;
            } else if (rhs.snsList.size() - lhs.snsList.size() < 0) {
                return -1;
            } else {
                return 0;
            }
        }
    });

    UserSnsInfo userSnsInfo2=null;
    for (int i=0;i<snsSizeRank.size();i++) {
        userSnsInfo2 = snsSizeRank.get(i);
        CheckBox userCheckBox = new CheckBox(this);
        userCheckBox.setText(userSnsInfo2.authorName + "(" + userSnsInfo2.userId + ")" + "(" + String.format(getString(R.string.user_moment_count), userSnsInfo2.snsList.size()) + ")");
        userListContainer.addView(userCheckBox);
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)userCheckBox.getLayoutParams();
        layoutParams.setMargins(5, 5, 5, 5);
        userCheckBox.setLayoutParams(layoutParams);
        userCheckBox.setChecked(true);
        userCheckBox.setTag(userSnsInfo2.userId);
        checkBoxList.add(userCheckBox);
    }
}
 
Example 8
Source File: BaseDialog.java    From TestChat with Apache License 2.0 5 votes vote down vote up
public BaseDialog setCheckBoxName(List<String> list) {
        if (middleLayout.getChildCount() > 0) {
                middleLayout.removeAllViews();
        }
        for (String title :
                list) {
                TextView textView = new TextView(getContext());
                textView.setGravity(Gravity.START);
                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                layoutParams.weight = 1;
                textView.setLayoutParams(layoutParams);
                textView.setText(title);
                final CheckBox checkBox = new CheckBox(getContext());
                checkBox.setGravity(Gravity.END);
                LinearLayout.LayoutParams checkBoxLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                checkBoxLayout.weight = 1;
                checkBox.setLayoutParams(checkBoxLayout);
                LinearLayout linearLayout = new LinearLayout(getContext());
                LinearLayout.LayoutParams linearLayoutParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                linearLayout.setGravity(Gravity.CENTER_VERTICAL);
                linearLayout.setWeightSum(2);
                linearLayout.setLayoutParams(linearLayoutParam);
                linearLayout.addView(textView);
                linearLayout.addView(checkBox);
                middleLayout.addView(linearLayout);
        }
        return this;
}
 
Example 9
Source File: BaseDialog.java    From TestChat with Apache License 2.0 5 votes vote down vote up
public BaseDialog setCheckBoxName(List<String> list) {
        if (middleLayout.getChildCount() > 0) {
                middleLayout.removeAllViews();
        }
        for (String title :
                list) {
                TextView textView = new TextView(getContext());
                textView.setGravity(Gravity.START);
                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                layoutParams.weight = 1;
                textView.setLayoutParams(layoutParams);
                textView.setText(title);
                final CheckBox checkBox = new CheckBox(getContext());
                checkBox.setGravity(Gravity.END);
                LinearLayout.LayoutParams checkBoxLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                checkBoxLayout.weight = 1;
                checkBox.setLayoutParams(checkBoxLayout);
                LinearLayout linearLayout = new LinearLayout(getContext());
                LinearLayout.LayoutParams linearLayoutParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                linearLayout.setGravity(Gravity.CENTER_VERTICAL);
                linearLayout.setWeightSum(2);
                linearLayout.setLayoutParams(linearLayoutParam);
                linearLayout.addView(textView);
                linearLayout.addView(checkBox);
                middleLayout.addView(linearLayout);
        }
        return this;
}
 
Example 10
Source File: BaseDialog.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
public BaseDialog setCheckBoxName(List<String> list) {
    if (middleLayout.getChildCount() > 0) {
        middleLayout.removeAllViews();
    }
    for (String title :
            list) {
        TextView textView = new TextView(getContext());
        textView.setGravity(Gravity.START);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.weight = 1;
        textView.setLayoutParams(layoutParams);
        textView.setText(title);
        final CheckBox checkBox = new CheckBox(getContext());
        checkBox.setGravity(Gravity.END);
        LinearLayout.LayoutParams checkBoxLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        checkBoxLayout.weight = 1;
        checkBox.setLayoutParams(checkBoxLayout);
        LinearLayout linearLayout = new LinearLayout(getContext());
        LinearLayout.LayoutParams linearLayoutParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        linearLayout.setGravity(Gravity.CENTER_VERTICAL);
        linearLayout.setWeightSum(2);
        linearLayout.setLayoutParams(linearLayoutParam);
        linearLayout.addView(textView);
        linearLayout.addView(checkBox);
        middleLayout.addView(linearLayout);
    }
    return this;
}
 
Example 11
Source File: DebugDialogView.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
private void initDebugCheckBox() {
    mDebugCheckBox = new CheckBox(mContext);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    mDebugCheckBox.setLayoutParams(params);
    mDebugCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {
            if (isChecked && mPreCheckoutBox.isChecked()) {
                mPreCheckoutBox.setChecked(false);
            }
        }
    });
}
 
Example 12
Source File: DebugDialogView.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
private void initLoggingCheckBox() {
    mLogCheckBox = new CheckBox(mContext);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    mLogCheckBox.setText("是否开启log信息?");
    mLogCheckBox.setLayoutParams(params);
}
 
Example 13
Source File: DialogPreferenceMenuHideGames.java    From Simple-Solitaire with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onBindDialogView(View view) {
    LinearLayout container = view.findViewById(R.id.layoutContainer);

    linearLayouts.clear();
    checkBoxes.clear();

    ArrayList<Integer> results = lg.getMenuShownList();
    gameOrder = lg.getOrderedGameList();

    TypedValue typedValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true);
    int padding = (int) (getContext().getResources().getDimension(R.dimen.dialog_menu_layout_padding));
    int margin = (int) (getContext().getResources().getDimension(R.dimen.dialog_menu_button_margin));
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(margin, 0, margin, 0);

    ArrayList<String> sortedGameList = lg.getOrderedGameNameList(getContext().getResources());

    for (int i = 0; i < lg.getGameCount(); i++) {
        LinearLayout entry = new LinearLayout(getContext());
        entry.setBackgroundResource(typedValue.resourceId);
        entry.setPadding(padding, padding, padding, padding);
        entry.setOnClickListener(this);

        CheckBox checkBox = new CheckBox(getContext());
        checkBox.setLayoutParams(layoutParams);
        int index = gameOrder.indexOf(i);
        checkBox.setChecked(results.get(index) == 1);

        TextView textView = new TextView(getContext());
        textView.setTypeface(null, Typeface.BOLD);
        textView.setText(sortedGameList.get(i));

        entry.addView(checkBox);
        entry.addView(textView);

        checkBoxes.add(checkBox);
        linearLayouts.add(entry);

        container.addView(entry);
    }


    super.onBindDialogView(view);
}
 
Example 14
Source File: TextDetailDocumentsCell.java    From SSForms with GNU General Public License v3.0 4 votes vote down vote up
@SuppressLint("RtlHardcoded")
public TextDetailDocumentsCell(Context context) {

    super(context);

    density = context.getResources().getDisplayMetrics().density;
    checkDisplaySize();

    textView = new TextView(context);
    textView.setTextColor(0xff212121);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity(Gravity.LEFT);
    addView(textView);
    LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
    layoutParams.width = LayoutParams.WRAP_CONTENT;
    layoutParams.height = LayoutParams.WRAP_CONTENT;
    layoutParams.topMargin = AndroidUtilities.dp(10, density);
    layoutParams.leftMargin = AndroidUtilities.dp(71, density);
    layoutParams.rightMargin = AndroidUtilities.dp(16, density);
    layoutParams.gravity = Gravity.LEFT;
    textView.setLayoutParams(layoutParams);

    valueTextView = new TextView(context);
    valueTextView.setTextColor(0xff8a8a8a);
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setGravity(Gravity.LEFT);
    addView(valueTextView);
    layoutParams = (LayoutParams) valueTextView.getLayoutParams();
    layoutParams.width = LayoutParams.WRAP_CONTENT;
    layoutParams.height = LayoutParams.WRAP_CONTENT;
    layoutParams.topMargin = AndroidUtilities.dp(35, density);
    layoutParams.leftMargin = AndroidUtilities.dp(71, density);
    layoutParams.rightMargin = AndroidUtilities.dp(16, density);
    layoutParams.gravity = Gravity.LEFT;
    valueTextView.setLayoutParams(layoutParams);

    typeTextView = new TextView(context);
    typeTextView.setBackgroundColor(0xff757575);
    typeTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
    typeTextView.setGravity(Gravity.CENTER);
    typeTextView.setSingleLine(true);
    typeTextView.setTextColor(0xffd1d1d1);
    typeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    typeTextView.setTypeface(Typeface.DEFAULT_BOLD);
    addView(typeTextView);
    layoutParams = (LayoutParams) typeTextView.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(40, density);
    layoutParams.height = AndroidUtilities.dp(40, density);
    layoutParams.leftMargin = AndroidUtilities.dp(16, density);
    layoutParams.rightMargin = AndroidUtilities.dp(0, density);
    layoutParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
    typeTextView.setLayoutParams(layoutParams);

    imageView = new ImageView(context);
    addView(imageView);
    layoutParams = (LayoutParams) imageView.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(40, density);
    layoutParams.height = AndroidUtilities.dp(40, density);
    layoutParams.leftMargin = AndroidUtilities.dp(16, density);
    layoutParams.rightMargin = AndroidUtilities.dp(0, density);
    layoutParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
    imageView.setLayoutParams(layoutParams);

    checkBox = new CheckBox(context);
    checkBox.setVisibility(GONE);
    addView(checkBox);
    layoutParams = (LayoutParams) checkBox.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(22, density);
    layoutParams.height = AndroidUtilities.dp(22, density);
    layoutParams.topMargin = AndroidUtilities.dp(34, density);
    layoutParams.leftMargin = AndroidUtilities.dp(38, density) ;
    layoutParams.rightMargin = 0;
    layoutParams.gravity = Gravity.LEFT;
    checkBox.setLayoutParams(layoutParams);
}
 
Example 15
Source File: OBooleanField.java    From hr with GNU Affero General Public License v3.0 4 votes vote down vote up
public void initControl() {
    mReady = false;
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    removeAllViews();
    setOrientation(VERTICAL);
    if (isEditable()) {
        if (mWidget != null) {
            switch (mWidget) {
                case Switch:
                    mSwitch = new Switch(mContext);
                    mSwitch.setLayoutParams(params);
                    mSwitch.setOnCheckedChangeListener(this);
                    setValue(getValue());
                    if (mLabel != null)
                        mSwitch.setText(mLabel);
                    if (textSize > -1) {
                        mSwitch.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
                    }
                    if (appearance > -1) {
                        mSwitch.setTextAppearance(mContext, appearance);
                    }
                    mSwitch.setTextColor(textColor);
                    addView(mSwitch);
                    break;
                default:
                    break;
            }
        } else {
            mCheckbox = new CheckBox(mContext);
            mCheckbox.setLayoutParams(params);
            mCheckbox.setOnCheckedChangeListener(this);
            if (mLabel != null)
                mCheckbox.setText(mLabel);
            if (textSize > -1) {
                mCheckbox.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
            }
            if (appearance > -1) {
                mCheckbox.setTextAppearance(mContext, appearance);
            }
            mCheckbox.setTextColor(textColor);
            addView(mCheckbox);
        }
    } else {
        txvView = new TextView(mContext);
        txvView.setLayoutParams(params);
        txvView.setText(getCheckBoxLabel());
        if (mLabel != null)
            txvView.setText(mLabel);
        if (textSize > -1) {
            txvView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        }
        if (appearance > -1) {
            txvView.setTextAppearance(mContext, appearance);
        }
        addView(txvView);
    }
}
 
Example 16
Source File: OBooleanField.java    From framework with GNU Affero General Public License v3.0 4 votes vote down vote up
public void initControl() {
    mReady = false;
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    removeAllViews();
    setOrientation(VERTICAL);
    if (isEditable()) {
        if (mWidget != null) {
            switch (mWidget) {
                case Switch:
                    mSwitch = new Switch(mContext);
                    mSwitch.setLayoutParams(params);
                    mSwitch.setOnCheckedChangeListener(this);
                    setValue(getValue());
                    if (mLabel != null)
                        mSwitch.setText(mLabel);
                    if (textSize > -1) {
                        mSwitch.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
                    }
                    if (appearance > -1) {
                        mSwitch.setTextAppearance(mContext, appearance);
                    }
                    mSwitch.setTextColor(textColor);
                    addView(mSwitch);
                    break;
                default:
                    break;
            }
        } else {
            mCheckbox = new CheckBox(mContext);
            mCheckbox.setLayoutParams(params);
            mCheckbox.setOnCheckedChangeListener(this);
            if (mLabel != null)
                mCheckbox.setText(mLabel);
            if (textSize > -1) {
                mCheckbox.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
            }
            if (appearance > -1) {
                mCheckbox.setTextAppearance(mContext, appearance);
            }
            mCheckbox.setTextColor(textColor);
            addView(mCheckbox);
        }
    } else {
        txvView = new TextView(mContext);
        txvView.setLayoutParams(params);
        txvView.setText(getCheckBoxLabel());
        if (mLabel != null)
            txvView.setText(mLabel);
        if (textSize > -1) {
            txvView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        }
        if (appearance > -1) {
            txvView.setTextAppearance(mContext, appearance);
        }
        addView(txvView);
    }
}
 
Example 17
Source File: DebugDialogView.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
private void initReportCheckBox() {
    mReportCheckBox = new CheckBox(mContext);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    mReportCheckBox.setLayoutParams(params);
}