本文整理汇总了Java中android.widget.RadioGroup.LayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java RadioGroup.LayoutParams方法的具体用法?Java RadioGroup.LayoutParams怎么用?Java RadioGroup.LayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RadioGroup
的用法示例。
在下文中一共展示了RadioGroup.LayoutParams方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAdapter
import android.widget.RadioGroup; //导入方法依赖的package包/类
/**
* 设置适配器
*
* @param adapter 适配器
*/
public void setAdapter(NavAdapter adapter) {
//动态生成菜单
int pageCount = adapter.getCount();
RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(RadioGroup.LayoutParams
.WRAP_CONTENT, RadioGroup.LayoutParams.MATCH_PARENT, 1);
//先移除所有的菜单项
rgTabs.removeAllViews();
for (int i = 0; i < pageCount; i++) {
BGABadgeRadioButton tab = (BGABadgeRadioButton) LayoutInflater.from(getContext())
.inflate(R.layout.view_nav_tab, null);
tab.setLayoutParams(params);
tab.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(adapter
.getTabIconId(i)), null, null);
tab.setText(adapter.getPageTitle(i));
tab.setTextColor(mNavTextDefaultColor);
tab.setTag(i);
rgTabs.addView(tab, i);
}
//从适配器获取页面缓存
mCache = adapter.getPagerCache();
//设置ViewPager适配器
vpContent.setAdapter(adapter);
//设置默认选中的菜单选项
((RadioButton) rgTabs.getChildAt(vpContent.getCurrentItem())).setChecked(true);
//设置选中项样式
setTabStyle((RadioButton) rgTabs.getChildAt(vpContent.getCurrentItem()), true);
//初始化事件
initListener();
//绑定适配器与BtgView,为了在适配器中能获取到BtgView中的某些数据,比如当前页面
adapter.bindTpgView(this);
}
示例2: addIndex
import android.widget.RadioGroup; //导入方法依赖的package包/类
/**
* 添加指示器
*/
private void addIndex(){
RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(10,0,10,0);
RadioButton radioButton = new RadioButton(getContext());
radioButton.setLayoutParams(layoutParams);
radioButton.setButtonDrawable(indicatorResId);
radioButton.setEnabled(false);
buttons.add(radioButton);
}
示例3: getRadios
import android.widget.RadioGroup; //导入方法依赖的package包/类
private static View getRadios(Activity activity, LayoutInflater inflater, final SignUpEventOptions options) {
View view = inflater.inflate(R.layout.event_sign_up_radios, null);
((TextView) view.findViewById(R.id.tv_label)).setText(options.getLabel() + (options.isRequired() ? "" : "(选填)") + ":");
RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.rg_options);
RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMarginEnd(100);
if (!TextUtils.isEmpty(options.getOption())) {
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++) {
RadioButton button = new RadioButton(activity);
button.setLayoutParams(params);
button.setText(list[i]);
if (!TextUtils.isEmpty(options.getDefaultValue())) {
button.setChecked(list[0].equals(options.getDefaultValue()));
options.setValue(options.getDefaultValue());
} else {
button.setChecked(i == 0);
options.setValue(list[0]);
}
boolean enable;
if (status == null)
enable = true;
else if (status.length <= i)
enable = true;
else
enable = "0".equals(status[0]);
button.setId(i);
button.setEnabled(enable);
radioGroup.addView(button);
}
}
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
String s[] = options.getOption().split(";");
if (s != null)
options.setValue(s[checkedId]);
}
});
return view;
}
示例4: getCheckBox
import android.widget.RadioGroup; //导入方法依赖的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;
}