本文整理汇总了Java中android.widget.RadioButton.setBackgroundResource方法的典型用法代码示例。如果您正苦于以下问题:Java RadioButton.setBackgroundResource方法的具体用法?Java RadioButton.setBackgroundResource怎么用?Java RadioButton.setBackgroundResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RadioButton
的用法示例。
在下文中一共展示了RadioButton.setBackgroundResource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNavigatorButton
import android.widget.RadioButton; //导入方法依赖的package包/类
@Override
public RadioButton getNavigatorButton(int position, ViewGroup parent) {
RadioButton rb = (RadioButton) LayoutInflater.from(mContext).inflate(R.layout.radio_btn_segmented, parent, false);
if (position == 0) {
rb.setBackgroundResource(R.drawable.segmented_control_first);
} else if (position == getCount() - 1) {
rb.setBackgroundResource(R.drawable.segmented_control_last);
} else {
rb.setBackgroundResource(R.drawable.segmented_control);
}
rb.setText(getPageTitle(position));
return rb;
}
示例2: 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);
}
}
示例3: initView
import android.widget.RadioButton; //导入方法依赖的package包/类
private void initView() {
String[] btnNameArr = groupBtnName.split("#");
String[] btnCodeArr = groupBtnCode.split("#");
Log.d("gyw", btnNameArr.length + " length :" + btnCodeArr.length);
if ((btnNameArr.length < 2) || (btnCodeArr.length < 2)) {
throw new RuntimeException("names和codes的格式不正确...");
}
for (int i = 0; i < btnCodeArr.length; i++) {
//使用布局文件写方便
RadioButton rb = (RadioButton) View.inflate(mContext, R.layout.view_item_group_radio_button, null);
if (btnCodeArr.length == 2) {
if (i == 0) {
rb.setBackgroundResource(R.drawable.left_button_selector);
rb.setChecked(true);
} else if (i == 1) {
rb.setBackgroundResource(R.drawable.right_button_selector);
}
} else {
if (i == 0) {
rb.setBackgroundResource(R.drawable.left_button_selector);
rb.setChecked(true);
} else if (i == btnCodeArr.length - 1) {
rb.setBackgroundResource(R.drawable.right_button_selector);
} else {
rb.setBackgroundResource(R.drawable.mid_button_selector);
}
}
rb.setId(i);
rb.setTag(btnCodeArr[i]);
rb.setText(btnNameArr[i]);
mRg.addView(rb);
}
}