本文整理汇总了Java中android.widget.RadioButton.setOnCheckedChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java RadioButton.setOnCheckedChangeListener方法的具体用法?Java RadioButton.setOnCheckedChangeListener怎么用?Java RadioButton.setOnCheckedChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RadioButton
的用法示例。
在下文中一共展示了RadioButton.setOnCheckedChangeListener方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import android.widget.RadioButton; //导入方法依赖的package包/类
/**
* 初始化界面。
*/
private void initialize(Context context) {
LayoutInflater.from(context).inflate(R.layout.share_item_template, this);
mTitleView = (TextView)findViewById(R.id.item_title_view);
mThumbView = (ImageView)findViewById(R.id.item_thumb_image_btn);
mShareTitleView = (TextView)findViewById(R.id.item_share_title_view);
mShareDescView = (TextView)findViewById(R.id.item_share_desc_view);
mShareUrlView = (TextView)findViewById(R.id.item_share_url_view);
mCheckedBtn = (RadioButton)findViewById(R.id.item_checked_btn);
mCheckedBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (mOnCheckedChangeListener != null) {
mOnCheckedChangeListener.onCheckedChanged(WBShareItemView.this, isChecked);
}
}
});
}
示例2: setCheckedId
import android.widget.RadioButton; //导入方法依赖的package包/类
/** 查找复合控件并设置id */
private void setCheckedId(ViewGroup vg) {
int len = vg.getChildCount();
for (int i = 0; i < len; i++) {
if (vg.getChildAt(i) instanceof RadioButton) {// 如果找到了,就设置check状态
final RadioButton button = (RadioButton) vg.getChildAt(i);
int id = button.getId();
// generates an id if it's missing
if (id == View.NO_ID) {
id = button.hashCode();
button.setId(id);
}
button.setOnCheckedChangeListener(mChildOnCheckedChangeListener);
} else if (vg.getChildAt(i) instanceof ViewGroup) {// 迭代查找并设置
ViewGroup childVg = (ViewGroup) vg.getChildAt(i);
setCheckedId(childVg);
}
}
}
示例3: onChildViewAdded
import android.widget.RadioButton; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void onChildViewAdded(View parent, View child) {
if (parent == MultiRadioGroup.this ) {
List<RadioButton> btns = getAllRadioButton(child);
if(btns != null && btns.size() > 0){
for(RadioButton btn : btns){
int id = btn.getId();
// generates an id if it's missing
if (id == View.NO_ID && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
id = View.generateViewId();
btn.setId(id);
}
btn.setOnCheckedChangeListener(
mChildOnCheckedChangeListener);
}
}
}
if (mOnHierarchyChangeListener != null) {
mOnHierarchyChangeListener.onChildViewAdded(parent, child);
}
}
示例4: setChecked
import android.widget.RadioButton; //导入方法依赖的package包/类
@BindingAdapter({"checked", "model"})
public static <T> void setChecked(RadioButton radioButton, final ObservableField<T> checked, final T model) {
if (checked == null) {
return;
}
radioButton.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
if ((checked.get() == null || !checked.get().equals(model))
&& isChecked) {
checked.set(model);
}
});
final T checkedModel = checked.get();
final boolean shouldBeChecked = checkedModel != null && checkedModel.equals(model);
if (shouldBeChecked != radioButton.isChecked()) {
radioButton.setChecked(shouldBeChecked);
}
}
示例5: makeRadioButton
import android.widget.RadioButton; //导入方法依赖的package包/类
private RadioButton makeRadioButton(RadioGroup baks, final String bk, final boolean item) {
RadioButton bkb = new RadioButton(this);
bkb.setText(bk);
bkb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (b) {
selectedBackup = bk;
selected = item;
Log.d("backuppage", "selected = " + selectedBackup);
backupSelected(selected);
}
}
});
baks.addView(bkb);
return bkb;
}
示例6: newRadioButton
import android.widget.RadioButton; //导入方法依赖的package包/类
private RadioButton newRadioButton(Condition condition) {
final RadioButton button = new RadioButton(mContext);
button.setTag(condition);
button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setCondition((Condition) button.getTag());
}
}
});
addView(button);
return button;
}
示例7: initView
import android.widget.RadioButton; //导入方法依赖的package包/类
private void initView() {
v=LayoutInflater.from(getContext()).inflate(R.layout.tariff_view, null);
jarak=(TextView) v.findViewById(R.id.tariffviewJarak);
oldprice=(TextView) v.findViewById(R.id.tariffviewOldPrice);
normprice=(TextView) v.findViewById(R.id.tariffviewNormalPrice);
lowprice=(TextView) v.findViewById(R.id.tariffviewLowPrice);
reload=(TextView) v.findViewById(R.id.tariffviewReload);
rb1=(RadioButton) v.findViewById(R.id.sbRadioButton1);
rb2=(RadioButton) v.findViewById(R.id.sbRadioButton2);
jarakBar=v.findViewById(R.id.tariffviewLinearLayout1);
myLoc=v.findViewById(R.id.tariffviewMyLoc);
rootv=v.findViewById(R.id.tariffviewLinearLayout2);
oldprice.setPaintFlags(oldprice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
myLoc.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View p1) {
if(callmyloc!=null) callmyloc.onMyLocationButtonClick();
}
});
post(new Runnable(){
@Override
public void run() {
myHeight=getHeight();
}
});
rb1.setOnCheckedChangeListener(this);
rb2.setOnCheckedChangeListener(this);
rb2.setChecked(true);
addView(v);
}
示例8: onCreateView
import android.widget.RadioButton; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_discover, container, false);
moviesRadioButton = (RadioButton) view.findViewById(R.id.radio_movies);
moviesRadioButton.setOnCheckedChangeListener(this);
tvRadioButton = (RadioButton) view.findViewById(R.id.radio_tv);
TextView discoverButton = (TextView) view.findViewById(R.id.discover_discover);
discoverButton.setOnClickListener(this);
LinearLayout genres = (LinearLayout) view.findViewById(R.id.genres_root);
genres.setOnClickListener(this);
genresView = (TextView) view.findViewById(R.id.discover_genres);
Spinner sortSpinner = (Spinner) view.findViewById(R.id.discover_sort);
ratingView = (TextView) view.findViewById(R.id.discover_rating);
AppCompatSeekBar ratingSeekBar = (AppCompatSeekBar) view.findViewById(R.id.discover_rating_bar);
mGenresList = new HashSet<>();
mGenresValuesList = new HashSet<>();
checkedGenres = new boolean[] {
false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false
};
ratingSeekBar.setOnSeekBarChangeListener(this);
final List<String> sort = Arrays.asList(getResources().getStringArray(R.array.sort));
ArrayAdapter<String> adapter
= new ArrayAdapter<>(getActivity(), R.layout.spinner_item, sort);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sortSpinner.setAdapter(adapter);
sortSpinner.setOnItemSelectedListener(this);
return view;
}
示例9: setUpRadioButton
import android.widget.RadioButton; //导入方法依赖的package包/类
public static void setUpRadioButton(Dialog dialog, @IdRes int checkBoxId, final IChartModifier modifier) {
final RadioButton radioButton = (RadioButton) dialog.findViewById(checkBoxId);
radioButton.setChecked(modifier.getIsEnabled());
radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
modifier.setIsEnabled(isChecked);
}
});
}
示例10: onChildViewRemoved
import android.widget.RadioButton; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void onChildViewRemoved(View parent, View child) {
if (parent == MultiRadioGroup.this) {
List<RadioButton> buttons = getAllRadioButton(child);
if(buttons != null && buttons.size() > 0){
for(RadioButton button : buttons){
button.setOnCheckedChangeListener(null);
}
}
}
if (mOnHierarchyChangeListener != null) {
mOnHierarchyChangeListener.onChildViewRemoved(parent, child);
}
}
示例11: setSingleSelectItems
import android.widget.RadioButton; //导入方法依赖的package包/类
public void setSingleSelectItems(String[] singleSelectItems, int selectedItem, final OnClickListener onClickListener) {
if (singleSelectItems != null && singleSelectItems.length > 0) {
selectableItemsContainer.removeAllViews();
selectableItemsContainer.setVisibility(View.VISIBLE);
RadioGroup radioGroup = (RadioGroup) getLayoutInflater().inflate(R.layout.cfdialog_single_select_item_layout, selectableItemsContainer)
.findViewById(R.id.cfstage_single_select_radio_group);
radioGroup.removeAllViews();
for (int i = 0; i < singleSelectItems.length; i++) {
String item = singleSelectItems[i];
RadioButton radioButton = (RadioButton) getLayoutInflater().inflate(R.layout.cfdialog_single_select_radio_button_layout, null);
radioButton.setText(item);
radioButton.setId(i);
final int position = i;
if (position == selectedItem) {
radioButton.setChecked(true);
}
radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked && onClickListener != null) {
onClickListener.onClick(CFAlertDialog.this, position);
}
}
});
radioGroup.addView(radioButton);
}
} else {
selectableItemsContainer.setVisibility(View.GONE);
}
}
示例12: onCreate
import android.widget.RadioButton; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
builder = TextCounter.newBuilder();
textView = (TextView) findViewById(R.id.textView);
round = (TextView) findViewById(R.id.round);
fps = (TextView) findViewById(R.id.fps);
duration = (TextView) findViewById(R.id.duration);
swipe = (ImageView) findViewById(R.id.swipe);
swipe.setOnClickListener(this);
spinner = (Spinner) findViewById(R.id.spinner);
from = (EditText) findViewById(R.id.from);
to = (EditText) findViewById(R.id.to);
from.addTextChangedListener(this);
builder.setTextView(textView);
seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
seekBar2 = (SeekBar) findViewById(R.id.seekBar2);
seekBar3 = (SeekBar) findViewById(R.id.seekBar3);
seekBar1.setOnSeekBarChangeListener(this);
seekBar2.setOnSeekBarChangeListener(this);
seekBar3.setOnSeekBarChangeListener(this);
start = (Button) findViewById(R.id.start);
start.setOnClickListener(this);
button1 = (RadioButton) findViewById(R.id.radioButton1);
button2 = (RadioButton) findViewById(R.id.radioButton2);
button3 = (RadioButton) findViewById(R.id.radioButton3);
button4 = (RadioButton) findViewById(R.id.radioButton4);
button5 = (RadioButton) findViewById(R.id.radioButton5);
button6 = (RadioButton) findViewById(R.id.radioButton6);
button1.setOnCheckedChangeListener(this);
button2.setOnCheckedChangeListener(this);
button3.setOnCheckedChangeListener(this);
button4.setOnCheckedChangeListener(this);
button5.setOnCheckedChangeListener(this);
button6.setOnCheckedChangeListener(this);
button1.setChecked(true);
seekBar1.setProgress(0);
seekBar2.setProgress(24);
seekBar3.setProgress(1);
builder.setTextView(textView);
textView.setVisibility(View.VISIBLE);
}