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


Java CheckBox.setLayoutParams方法代碼示例

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


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

示例1: addItemTrainCategories

import android.widget.CheckBox; //導入方法依賴的package包/類
public ItemBuilder addItemTrainCategories(Context context) {
    view = inflater.inflate(R.layout.item_element_categories_checkboxes, parent, false);
    TextView      tv            = (TextView) view.findViewById(R.id.tv_title);
    TextView      tv2           = (TextView) view.findViewById(R.id.tv_subtitle);
    FlexboxLayout fblCategories = (FlexboxLayout) view.findViewById(R.id.fbl_categories);
    tv.setText("Categorie di treni incluse nella ricerca");
    tv2.setText(SettingsPreferences.getCategoriesAsString(context, " / "));
    for (ENUM_CATEGORIES cat : ENUM_CATEGORIES.values()) {
        CheckBox                   cbCat  = new CheckBox(context);
        FlexboxLayout.LayoutParams params = new FlexboxLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.flexBasisPercent = 0.5f;
        cbCat.setLayoutParams(params);
        cbCat.setText(cat.getAlias());
        cbCat.setChecked(SettingsPreferences.isCategoryEnabled(context, cat));
        cbCat.setOnCheckedChangeListener((buttonView, isChecked) -> {
            if (isChecked || (!isChecked && SettingsPreferences.isPossibleToDisableCheckbox(context))) {
                SettingsPreferences.setCategory(context, cat.name(), isChecked);
                tv2.setText(SettingsPreferences.getCategoriesAsString(context, " / "));
            } else {
                cbCat.setChecked(true);
            }
        });
        fblCategories.addView(cbCat);
    }
    return this;
}
 
開發者ID:albertogiunta,項目名稱:justintrain-client-android,代碼行數:27,代碼來源:ItemBuilder.java

示例2: setCheckBoxName

import android.widget.CheckBox; //導入方法依賴的package包/類
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;
}
 
開發者ID:HelloChenJinJun,項目名稱:TestChat,代碼行數:29,代碼來源:BaseDialog.java

示例3: getCheckBox

import android.widget.CheckBox; //導入方法依賴的package包/類
private static View getCheckBox(Activity activity, LayoutInflater inflater, final SignUpEventOptions options) {
    View view = inflater.inflate(R.layout.event_sign_up_check_box, null);
    FlowLayout ll_check_box = (FlowLayout) view.findViewById(R.id.fl_check_box);
    ((TextView) view.findViewById(R.id.tv_label)).setText(options.getLabel() + (options.isRequired() ? "" : "(選填)") + ":");
    RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMarginEnd(100);
    if (options.getSelectList() == null)
        options.setSelectList(new ArrayList<String>());
    if (!TextUtils.isEmpty(options.getOption())) {
        final String[] list = options.getOption().split(";");
        String[] status = null;
        if (!TextUtils.isEmpty(options.getOptionStatus()))
            status = options.getOptionStatus().split(";");
        for (int i = 0; i < list.length; i++) {
            final CheckBox button = new CheckBox(activity);
            button.setLayoutParams(params);
            button.setText(list[i]);
            boolean enable;
            if (status == null)
                enable = true;
            else if (status.length <= i)
                enable = true;
            else
                enable = "0".equals(status[i]);
            button.setId(i);
            button.setEnabled(enable);
            button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    String item = list[button.getId()];
                    if (isChecked) {
                        options.getSelectList().add(item);
                    } else {
                        options.getSelectList().remove(item);
                    }
                }
            });
            ll_check_box.addView(button);
        }
    }
    return view;
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:45,代碼來源:ViewFactory.java


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