本文整理汇总了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;
}
示例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;
}
示例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;
}