radio-group

Custom layout for RadioButton

痴心易碎 提交于 2019-11-27 23:37:40
问题 Is there any way I can change the layout for a RadioButton and still have the RadioGroup recognise it? what I need is that the layout will include a couple of EditText fields so that when the user selected that button those fields become active. I know I can built a custom part based on LinearLayout and set my own layout using: (LinearLayout) LayoutInflater.from(context).inflate(R.layout.my_layout, this, true) but can't figure out how to do the same thing with a radio button. I have tried the

Get the array of RadioButtons in a RadioGroup in Android

て烟熏妆下的殇ゞ 提交于 2019-11-27 21:53:49
Is there any way of getting an array (or a collection) of the RadioButton s in an Android RadioGroup ? I would like to add individual listeners to radio buttons but I don't see any obvious way of iterating over them. this should do the trick: int count = radioGroup.getChildCount(); ArrayList<RadioButton> listOfRadioButtons = new ArrayList<RadioButton>(); for (int i=0;i<count;i++) { View o = radioGroup.getChildAt(i); if (o instanceof RadioButton) { listOfRadioButtons.add((RadioButton)o); } } Log.d(TAG,"you have "+listOfRadioButtons.size()+" radio buttons"); Why do you need to query the

How to disable a RadioGroup until checkbox is checked

僤鯓⒐⒋嵵緔 提交于 2019-11-27 20:26:27
I have a radio group which I do not want to user to be able to select any of the buttons until a particular checkbox is selected within my app. If the checkbox is unticked then this disables the radio-group. How do I go about doing this. The real trick is to loop through all children view (in this case: CheckBox ) and call it's setEnabled(boolean) Something like this should do the trick: //initialize the controls final RadioGroup rg1 = (RadioGroup)findViewById(R.id.radioGroup1); CheckBox ck1 = (CheckBox)findViewById(R.id.checkBox1); //set setOnCheckedChangeListener() ck1

AngularJs: How to set radio button checked based on model

最后都变了- 提交于 2019-11-27 19:13:30
I have a model returning in the storeLocations object with a isDefault value. if isDefault returns true, I wan't to set that radio button in the group as checked. Not sure if I need to do a $each(data, function(index,value) and iterate through each object returned or if there's an easier way to do this using angular constructs. Object: storeLocations = [ { ... more values, isDefault: true } ] Markup: <tr ng-repeat="location in merchant.storeLocations"> <td>{{location.name}}</td> <td>{{location.address.address1}}</td> <td>{{location.address.address2}}</td> <td>{{location.address.city}}</td> <td

How to check if a radiobutton is checked in a radiogroup in Android?

时间秒杀一切 提交于 2019-11-27 17:29:40
I need to set validation that user must fill / select all details in a page. If any fields are empty wanna show Toast message to fill. Now I need set validation for RadioButton in the RadioGroup. I tried this code but didn't work properly. Suggest me correct way. Thankyou. // get selected radio button from radioGroup int selectedId = gender.getCheckedRadioButtonId(); // find the radiobutton by returned id selectedRadioButton = (RadioButton)findViewById(selectedId); // do what you want with radioButtonText (save it to database in your case) radioButtonText = selectedRadioButton.getText()

Making RadioGroup radio buttons with images in Android… How?

社会主义新天地 提交于 2019-11-27 14:37:26
问题 Is it possible to make Radio Buttons in Android, where there are image representation to a button instead of a regular buttons? I want it to look something like that: The cyan in the middle represents the selected button. How can I do it? 回答1: The RadioButton class has a buttonDrawable member, derived from CompoundButton. There are multiple ways you can change this drawable. From java: myRadioButton.setButtonDrawable(resourceId or Drawable); From xml: <RadioButton android:button="@drawable

Multiple radio button groups in MVC 4 Razor

白昼怎懂夜的黑 提交于 2019-11-27 13:26:53
I need to have multiple radio button groups in my form like this: I know it's simply done by specifying the same " name " html attribute for each group. HOWEVER MVC doesn't let you specify your own name attribute when using html helper like this: @Html.RadioButtonFor(i => item.id, item.SelectedID, new { Name = item.OptServiceCatId }) Because it looks at each tag's " name " attribute (not " id ") to map/bind the form to the model which the controller receives, etc. Some said that specifying each with the same "GroupName" attribute will solve the problem, but it didn't work either. So, is there

How to disable a RadioGroup until checkbox is checked

丶灬走出姿态 提交于 2019-11-27 04:27:28
问题 I have a radio group which I do not want to user to be able to select any of the buttons until a particular checkbox is selected within my app. If the checkbox is unticked then this disables the radio-group. How do I go about doing this. 回答1: The real trick is to loop through all children view (in this case: CheckBox ) and call it's setEnabled(boolean) Something like this should do the trick: //initialize the controls final RadioGroup rg1 = (RadioGroup)findViewById(R.id.radioGroup1); CheckBox

ListView with RadioGroup in each row

纵然是瞬间 提交于 2019-11-27 03:40:28
问题 Above shown is my custom listview with TextViews and RadioGroup. Based on whether the item status is "pending" or "served" I update the pending items-TextView (in red, on top). Everything is working as expected, and I am able to retain the RadioGroup selections on scroll. However, when I scroll, the pending Items TextView does not retain its value. It changes whenever the list scrolls. Here is my getView method. public View getView(final int position, View convertView, ViewGroup parent) {

RadioGroup: How to check programmatically

狂风中的少年 提交于 2019-11-27 03:01:25
问题 I create a RadioGroup from XML <RadioGroup android:id="@+id/option" android:layout_width="match_parent" android:orientation="horizontal" android:checkedButton="@+id/block_scenario_off" android:layout_height="wrap_content"> <RadioButton android:layout_width="0dip" android:layout_weight="1" android:text="@string/option1" android:layout_height="wrap_content" android:id="@+id/option1" android:layout_gravity="center|left" android:onClick="@string/on_click"/> <RadioButton android:layout_width="0dip