本文整理汇总了Java中android.widget.RadioButton.setLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java RadioButton.setLayoutParams方法的具体用法?Java RadioButton.setLayoutParams怎么用?Java RadioButton.setLayoutParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RadioButton
的用法示例。
在下文中一共展示了RadioButton.setLayoutParams方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setImage
import android.widget.RadioButton; //导入方法依赖的package包/类
public void setImage(ArrayList<Integer> imageList) {
for (int i = 0; i < imageList.size(); i++) {
Integer imageID = ((Integer) imageList.get(i)).intValue();
ImageView iv = new ImageView(mContext);
iv.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
iv.setScaleType(ImageView.ScaleType.FIT_XY);
iv.setImageResource(imageID);
iv.setOnClickListener(this);
mViewList.add(iv);
}
mPager.setAdapter(new ImageAdapater());
mPager.addOnPageChangeListener(new SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
setButton(position);
}
});
mCount = imageList.size();
for (int i = 0; i < mCount; i++) {
RadioButton radio = new RadioButton(mContext);
radio.setLayoutParams(new RadioGroup.LayoutParams(dip_15, dip_15));
radio.setGravity(Gravity.CENTER);
radio.setButtonDrawable(R.drawable.indicator_selector);
mGroup.addView(radio);
}
mPager.setCurrentItem(0);
setButton(0);
}
示例2: addIndex
import android.widget.RadioButton; //导入方法依赖的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.RadioButton; //导入方法依赖的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: initView
import android.widget.RadioButton; //导入方法依赖的package包/类
private void initView() {
final RadioGroup group = (RadioGroup) getView().findViewById(
R.id.ringtoneGroup);
RingtoneManager manager = new RingtoneManager(getActivity());
manager.setType(RingtoneManager.TYPE_RINGTONE);
int pdng = (int) (5 * getResources().getDisplayMetrics().density + .5f);
final String[] columns = {MediaStore.Images.Media.DATA,
MediaStore.Audio.Media._ID};
final String orderBy = MediaStore.Images.Media._ID;
Cursor imagecursor = getActivity().getContentResolver().query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, columns, null,
null, orderBy);
int dataColumnIndex = imagecursor
.getColumnIndex(MediaStore.Audio.Media.DATA);
for (int i = 0; i < imagecursor.getCount(); i++) {
imagecursor.moveToPosition(i);
final String uri = imagecursor.getString(dataColumnIndex);
final String title = uri.substring(uri.lastIndexOf("/") + 1);
RadioButton rb = new RadioButton(getActivity());
rb.setLayoutParams(new RadioGroup.LayoutParams(
RadioGroup.LayoutParams.MATCH_PARENT,
RadioGroup.LayoutParams.WRAP_CONTENT));
rb.setText(title);
rb.setTypeface(((OneSheeldApplication) getActivity()
.getApplication()).appFont);
rb.setGravity(Gravity.CENTER);
rb.setPadding(pdng, pdng, pdng, pdng);
rb.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
rb.setTextColor(getResources().getColor(R.color.textColorOnDark));
rb.setBackgroundResource(R.drawable.devices_list_item_selector);
rb.setTag(uri);
rb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((OneSheeldApplication) getActivity().getApplication())
.setBuzzerSound(uri);
}
});
group.addView(rb);
}
}