android-radiobutton

Checking RadioButton of RadioGroup in ListView checks other item button

半世苍凉 提交于 2019-12-06 15:36:39
here is adapter class..... public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder holder=null; Student temp = (Student) getItem(position); if (convertView == null) { convertView = mInflator.inflate(R.layout.item_class_student, null); holder = new ViewHolder(); holder.nameTextView = (TextView) convertView.findViewById(R.id.row_student_name); holder.classTextView = (TextView) convertView.findViewById(R.id.row_student_class); holder.rollNumberTextView = (TextView) convertView.findViewById(R.id.row_student_roll_number); holder.image = (ImageView) convertView

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

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 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()

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

Uncheck all RadioButton in a RadioButtonGroup

你。 提交于 2019-11-26 21:27:19
问题 What I wanted to achieve is this: Right after the activity starts, I want that no RadioButton is selected/checked. My problem is this: When the activity starts, the first RadioButton is always selected/checked. I tried radioButton1.setChecked(false) right after initialization of the radiobutton(inside onCreate), but when the activity starts, I can't manually check/select the first radiobutton. Till I select the 2nd or 3rd radio button, I can now select/check the first radio button. 回答1:

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

Android: RadioGroup - How to configure the event listener

为君一笑 提交于 2019-11-26 07:36:46
问题 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.

Change Circle color of radio button

六眼飞鱼酱① 提交于 2019-11-26 02:29:28
问题 I want to change the color of circle of RadioButton, I could not understand which property to set. The background color I am having is black so it gets invisible. I want to set the color of the circle to white. 回答1: More simple, just set the buttonTint color: (only works on api level 21 or above) <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/radio" android:checked="true" android:buttonTint="@color/your_color"/> in your values/colors.xml