android-radiogroup

How to set only one RadioButton Can be selected at the time in RadioGroup

点点圈 提交于 2019-12-03 19:51:10
问题 I've created a radio button in radiogroup, but when I try running the apps all radio button can be selected all the time, and how to set only one radiobutton can be selected at one time? I'm using Fragment RadioGroup radioGroup = (RadioGroup) rootView.findViewById(R.id.RGroup); radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { // find which radio button is selected if(checkedId == R.id

Radiogroup in recyclerview

杀马特。学长 韩版系。学妹 提交于 2019-12-03 13:49:31
问题 I am having a recyclerview where each list item has a radiogroup with 4 radio buttons. How can I store the state of each radiogroup correctly. Here is my code. On scrolling up/down the states are incorrects. Thanks public class ElementListAdapter extends RecyclerView.Adapter<ElementListAdapter.ViewHolder> { private List<Element> elements = new ArrayList<>(); private Context context; private int[] state; public ElementListAdapter(Context context, List<Element> elements) { this.context =

Radiogroup in recyclerview

不羁的心 提交于 2019-12-03 04:56:08
I am having a recyclerview where each list item has a radiogroup with 4 radio buttons. How can I store the state of each radiogroup correctly. Here is my code. On scrolling up/down the states are incorrects. Thanks public class ElementListAdapter extends RecyclerView.Adapter<ElementListAdapter.ViewHolder> { private List<Element> elements = new ArrayList<>(); private Context context; private int[] state; public ElementListAdapter(Context context, List<Element> elements) { this.context = context; this.elements = elements; this.state = new int[elements.size()]; Arrays.fill(this.state, -1); }

Set selected index of an Android RadioGroup

笑着哭i 提交于 2019-12-02 21:32:14
Is there a way to set the selected index of a RadioGroup in android, other than looping through the child radiobuttons and selecting checking the radio button at the selected index? Note: I am populating the Radio Button Group at run time. jjm If your radio group is defined in a layout xml file, each button can be assigned an id. Then you just check a button like this radioGroup.check(R.id.myButtonId); If you created your radio group programmatically (I'm not even sure how you do this...), you might want to consider creating a special layout xml file just for the radio group so that you can

How to bind method on RadioGroup on checkChanged event with data-binding

旧巷老猫 提交于 2019-12-02 20:59:16
I was searching over the internet for how to perform the new cool android data-binding over the RadioGroup and I didn't find a single blog post about it. Its a simple scenario, based on the radio button selected, I want to attach a callback event using android data binding. I don't find any method on the xml part which allows me to define a callback. Like here is my RadioGroup: <RadioGroup android:id="@+id/split_type_radio" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:checkedButton="@+id/split_type_equal" android:gravity=

How to get id of selected radio button in a radio group

时光毁灭记忆、已成空白 提交于 2019-12-01 14:20:42
I am making a quiz app in which I have a viewPager which has 15 pages in it having 1 question each and a submit button at the last page.Now I want to get the Maximum number of option selected among 15 questions. Below is my code QuestionPagerFragment.java: public class QuestionPagerFragment extends Fragment { protected View mView; String pageData[]; //Stores the text to swipe. String optionData[];//Stores the option data. int rid; RadioGroup group; String ans; String ans1; String ans2; SharedPreferences prefs; public static final String MyPREFERENCES = "MyPrefs" ; @Nullable @Override public

How to set only one RadioButton Can be selected at the time in RadioGroup

梦想的初衷 提交于 2019-11-30 11:31:44
I've created a radio button in radiogroup, but when I try running the apps all radio button can be selected all the time, and how to set only one radiobutton can be selected at one time? I'm using Fragment RadioGroup radioGroup = (RadioGroup) rootView.findViewById(R.id.RGroup); radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { // find which radio button is selected if(checkedId == R.id.Abdominal) { Toast.makeText(getActivity().getApplicationContext(), "choice: A", Toast.LENGTH_SHORT).show()

Android radio group onCheckChangedListener crashing app

痞子三分冷 提交于 2019-11-29 12:45:43
Any idea why this would crash my app when I select a radio button? I've imported android.widget.RadioGroup.OnCheckedChangeListener , and I've also tried new RadioGroup.OnCheckedChangeListener() which was the solution to a similar post. The code is (logcat added): RadioGroup ringtone_radio_group = (RadioGroup)findViewById(R.id.ringtone_radio_group); ringtone_radio_group.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { Toast.makeText(getApplicationContext(), "checked id = " + checkedId, Toast.LENGTH_SHORT).show()

Radio Button is only partially checked

瘦欲@ 提交于 2019-11-29 09:21:41
I know this sound weird so here is the picture. It hold the correct value. The correct radiobutton is (partially) selected. All logic in the OnCheckedChangeListener is executed correctly. I'm completly stunned. Why is the radio button not fully checked? Only thing I can think of is that i'm using Rx2Firebase periodRetriever = FirebaseHelper.getInstance(getContext()).getPeriod() .defaultIfEmpty(0) .distinctUntilChanged() .subscribe(new Consumer<Integer>() { @Override public void accept(@NonNull Integer headerType) throws Exception { getRadioViewChecked(headerType).setChecked(true); } }); EDIT1

Android: RadioGroup - How to configure the event listener

被刻印的时光 ゝ 提交于 2019-11-26 20:23:15
From my understanding, to determine if a checkbox is "clicked" and find if it's checked or not, code such as the following can be used: cb=(CheckBox)findViewById(R.id.chkBox1); cb.setOnCheckedChangeListener(this); public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { cb.setText("This checkbox is: checked"); } else { cb.setText("This checkbox is: unchecked"); } } However, I am unable to work out the logic on how to do the above for a radiogroup. Here is the xml for my RadioGroup: <RadioGroup android:id="@+id/radioGroup1" android:layout_width="wrap_content