radio-group

Android RadioGroup checks more than one RadioButton?

本小妞迷上赌 提交于 2019-12-02 10:59:28
问题 I am using RadioGroup , added RadioButton rdbut to RadioGroup rdgrp like rdgrp.addView(rdbut) . for(int j=0;j<3;j++) { RadioGroup rdgrp = new RadioGroup; for(int i=0;i<=10;i++) { RadioButton rdbut = new RadioButton(this); rdbut.setText("RadioButtion"+i); rdbut.setId(i); rdbut.setTag("somename"); rdgrp.addView(rdbut); } } the above code shows how I initialize the radiogroup and radio button. after I run the this code, in emulator/mobile , i am able to check 2 radio buttons at a time. What

I can't create an onCheckedChanged listener for my RadioGroup

匆匆过客 提交于 2019-12-02 09:00:25
I'm trying to create an onCheckedChanged Listener for my RadioGroup, but eclipse is throwing erros at me. this is the code rg = (RadioGroup) findViewById(R.id.radioGroup1); rg.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { Log.d("chk", "id" + checkedId); if (checkedId == R.id.switchToFriends) { // some code } else if (checkedId == R.id.switchToUsers) { // some code } } }); And from eclipse I get an error on setOnCheckedChangeListener suggesting to change it to setOnClickListener/setOnDragListener, and others.

RadioGroup doesn't work properly

人走茶凉 提交于 2019-12-02 04:32:15
问题 I want to give the user four choices, the first and second choices on a row and the third and fourth choices on another row. My problem is when the application starts I can select more than one choice, but I don't want that. This is my xml layout: <RadioGroup android:id="@+id/rgAnswerQuestionChoices" android:layout_width="wrap_content" android:layout_height="wrap_content" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android

Android RadioGroup checks more than one RadioButton?

て烟熏妆下的殇ゞ 提交于 2019-12-02 03:59:00
I am using RadioGroup , added RadioButton rdbut to RadioGroup rdgrp like rdgrp.addView(rdbut) . for(int j=0;j<3;j++) { RadioGroup rdgrp = new RadioGroup; for(int i=0;i<=10;i++) { RadioButton rdbut = new RadioButton(this); rdbut.setText("RadioButtion"+i); rdbut.setId(i); rdbut.setTag("somename"); rdgrp.addView(rdbut); } } the above code shows how I initialize the radiogroup and radio button. after I run the this code, in emulator/mobile , i am able to check 2 radio buttons at a time. What could be the problem? Change your code like this. RadioGroup rdgrp[] = new RadioGroup[3]; For(int j=0;j<3;j

RadioGroup doesn't work properly

南笙酒味 提交于 2019-12-02 02:54:17
I want to give the user four choices, the first and second choices on a row and the third and fourth choices on another row. My problem is when the application starts I can select more than one choice, but I don't want that. This is my xml layout: <RadioGroup android:id="@+id/rgAnswerQuestionChoices" android:layout_width="wrap_content" android:layout_height="wrap_content" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="horizontal" > <RadioButton android:id="@+id

Set/Get values for RadioGroupFieldEditor in SWT

家住魔仙堡 提交于 2019-12-02 01:50:56
问题 I'm trying to add a RadioGroupFieldEditor in an Eclipse RCP application I'm developing, but seem unable to do two key things: set the value for the radio button (i.e. when the dialog/window is opened, I'd like to for example set the default to "button1") get the current value of the selected radio button (i.e. what has been selected by the user, or if nothing has been set, the default value set above). The code I'm using is as follows: String[][] radioButtonOptions = new String[][] { {

Set/Get values for RadioGroupFieldEditor in SWT

ぃ、小莉子 提交于 2019-12-02 00:47:12
I'm trying to add a RadioGroupFieldEditor in an Eclipse RCP application I'm developing, but seem unable to do two key things: set the value for the radio button (i.e. when the dialog/window is opened, I'd like to for example set the default to "button1") get the current value of the selected radio button (i.e. what has been selected by the user, or if nothing has been set, the default value set above). The code I'm using is as follows: String[][] radioButtonOptions = new String[][] { { "Button1" "button1" }, { "Button2" "button2" } }; RadioGroupFieldEditor radioButtonGroup = new

Android dynamic RadioGroup/RadioButtons as flat buttons

北战南征 提交于 2019-12-01 17:35:00
this is a similar issue to what is mentioned in a related post but I thought it was different enough to get its own question. Here it goes: I have been able to get the "radio circle" to disappear no problem when declaring the radio buttons in xml by setting the button attribute of the radio button to null like this: <RadioButton android:id="@+id/radioButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="One" android:background="@drawable/radio_button_selector" android:button="@null"/> But when i try and declare the radio buttons dynamically i cannot

android onCheckedChanged for radiogroup

被刻印的时光 ゝ 提交于 2019-12-01 02:44:13
I'm writing an Activity in android where I have two radio buttons under a RadioGroup. One of them is checked by default. But I can't trigger the event in onCreate method so that I can do something in that. The onCheckedChanged is running fine when clicked on. RadioGroup ItemtypeGroup = (RadioGroup) findViewById(R.id.rechargeItemtype); RadioButton providerRadio = (RadioButton) findViewById(R.id.a); providerRadio.performClick(); ItemtypeGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged (RadioGroup group,int checkedId){ Log.d("chk", "id" +

Android radiogroup, divider between radiobuttons

别说谁变了你拦得住时间么 提交于 2019-12-01 02:17:01
Is there a simple way to add a divider between RadioButtons inside a RadioGroup ? I've tried using the divider xml attribute and it doesn't seem to be working. In case it's relevant, the RadioGroup in my layout does not contain any child views; I'm adding the RadioButtons programmatically. EDIT : Problem solved. You can add views besides RadioButton inside RadioGroup in the xml. In my case, you can also do it programmatically, but be careful about your layout params. Akki had the right idea, and this worked for me: for (int i = 0; i < items.size(); i++) { if (i > 0) { // add a divider with