I am trying to disable my RadioGroup so that the user cannot re-select and therefore my score count rises. I have seen an implementation here:
How to disable a RadioGroup until checkbox is checked
Albeit tried to go about it this way
My xml:
<RadioGroup
android:id="#+id/rg1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/sm_margin"
android:orientation="horizontal">
<RadioButton
android:id="#+id/pates"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/sm_margin"
android:text="#string/pates"
android:onClick="onRadioButtonClicked" />
<RadioButton
android:id="#+id/chips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/sm_margin"
android:text="#string/chips"
android:onClick="onRadioButtonClicked" />
<RadioButton
android:id="#+id/frites"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/sm_margin"
android:text="#string/frites"
android:onClick="onRadioButtonClicked" />
<RadioButton
android:id="#+id/crepes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/def_margin"
android:layout_marginLeft="#dimen/sm_margin"
android:text="#string/crepes"
android:onClick="onRadioButtonClicked" />
</RadioGroup>
</LinearLayout>
<TextView
android:id="#+id/question2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/def_margin"
android:background="#drawable/layout_bg"
android:fontFamily="#font/cambria"
android:padding="#dimen/tv_padding"
android:text="#string/question2" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="70dp"
android:adjustViewBounds="true"
android:src="#drawable/jc_fav" />
<RadioGroup
android:id="#+id/rg2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/sm_margin"
android:orientation="vertical">
<RadioButton
android:id="#+id/mille_feuille"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/milleFeuille"
android:onClick="onRadioButtonClicked" />
<RadioButton
android:id="#+id/creme_chantilly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cremeChantilly"
android:onClick="onRadioButtonClicked" />
<RadioButton
android:id="#+id/opera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/opera"
android:onClick="onRadioButtonClicked" />
<RadioButton
android:id="#+id/creme_brulee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/def_margin"
android:text="#string/cremeBrulee"
android:onClick="onRadioButtonClicked" />
</RadioGroup>
Java:
int score = 0;
RadioGroup rgQ1;
RadioGroup rgQ2;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rgQ1 = findViewById(R.id.rg1);
rgQ2 = findViewById(R.id.rg2);
}
public void onRadioButtonClicked(View view) {
// Is the button now checked? then assign into a boolean named 'checked'
boolean checked = ((RadioButton) view).isChecked();
// Question 1 logic
// Check correct answer is checked and update score
switch (view.getId()) {
case R.id.frites:
if (checked) score += 1;
Log.v("MainActivity", "score" + score);
break;
}
// Disable RadioButtons of rg1
for (int i = 0; i < rgQ1.getChildCount(); i++) {
(rgQ1.getChildAt(i)).setEnabled(false);
}
// Question 2 logic
// Check correct answer is checked and update score
switch (view.getId()) {
case R.id.mille_feuille:
if (checked) score += 1;
Log.v("MainActivity", "score" + score);
break;
}
// Disable RadioButtons of rg2
for (int i = 0; i < rgQ2.getChildCount(); i++) {
(rgQ2.getChildAt(i)).setEnabled(false);
}
}
}
It disables the first radiogroup when an item is selected and also the 2nd (before a user has selected for the 2nd radiogroup.
Any ideas?
You are disabling your second radio group in the same click event. Check which radio button group is selected.
Like this, Similarly check group two and disable radio button group two!
int selectedId = radioGroup.getCheckedRadioButtonId();
if(selectedId != null){
//Then disable radio button group one
}
Related
I have 12 checkboxes and I need to make sure the user selects only 5 of them and then make the 5 choices labels enter into 5 different strings.
How can I do that?
This is my XML file:
<CheckBox
android:id="#+id/chkInterestsMovies"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="223dp"
android:layout_y="257dp"
android:text="סרטים" />
<CheckBox
android:id="#+id/chkInterestsAnimals"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="222dp"
android:layout_y="306dp"
android:text="חיות" />
<CheckBox
android:id="#+id/chkInterestsShopping"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="222dp"
android:layout_y="356dp"
android:text="קניות" />
<CheckBox
android:id="#+id/chkInterestsBooks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="149dp"
android:layout_y="257dp"
android:text="ספרים" />
<CheckBox
android:id="#+id/chkInterestsRestaurants"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="147dp"
android:layout_y="305dp"
android:text="מסעדות" />
<CheckBox
android:id="#+id/chkInterestsComputers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="153dp"
android:layout_y="356dp"
android:text="מחשבים" />
<CheckBox
android:id="#+id/chkInterestsTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="72dp"
android:layout_y="255dp"
android:text="טלויזיה" />
<CheckBox
android:id="#+id/chkInterestsPubs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="76dp"
android:layout_y="306dp"
android:text="פאבים" />
<CheckBox
android:id="#+id/chkInterestsDancing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="76dp"
android:layout_y="355dp"
android:text="ריקודים" />
<CheckBox
android:id="#+id/chkInterestsMusic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="7dp"
android:layout_y="257dp"
android:text="מוזיקה" />
<CheckBox
android:id="#+id/chkInterestsCoffe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="8dp"
android:layout_y="304dp"
android:text="בתי קפה" />
<CheckBox
android:id="#+id/chkInterestsOther"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="7dp"
android:layout_y="350dp"
android:text="אחר" />
You need to consider selecting and unselecting of checkboxes as well. At any given point, if user selected 5 among all, you can go forward with.
Roughly, in your onCreate
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.YOUR_LAYOUT);
//...
CheckBox checkboxMovies = (CheckBox)findViewById(R.id.chkInterestsMovies);
checkboxMovies.setOnCheckedChangeListener(this);
CheckBox checkboxAnimals = (CheckBox)findViewById(R.id.chkInterestsAnimals);
checkboxAnimals.setOnCheckedChangeListener(this);
CheckBox checkboxShopping = (CheckBox)findViewById(R.id.chkInterestsShopping);
checkboxShopping.setOnCheckedChangeListener(this);
CheckBox checkboxBooks = (CheckBox)findViewById(R.id.chkInterestsBooks);
checkboxBooks.setOnCheckedChangeListener(this);
CheckBox checkboxRestaurants = (CheckBox)findViewById(R.id.chkInterestsRestaurants);
checkboxRestaurants.setOnCheckedChangeListener(this);
CheckBox checkboxComputers = (CheckBox)findViewById(R.id.chkInterestsComputers);
checkboxComputers.setOnCheckedChangeListener(this);
CheckBox checkboxTV = (CheckBox)findViewById(R.id.chkInterestsTV);
checkboxTV.setOnCheckedChangeListener(this);
CheckBox checkboxPubs = (CheckBox)findViewById(R.id.chkInterestsPubs);
checkboxPubs.setOnCheckedChangeListener(this);
CheckBox checkboxDancing = (CheckBox)findViewById(R.id.chkInterestsDancing);
checkboxDancing.setOnCheckedChangeListener(this);
//...
}
& your onCheckedChanged
Map<String, String> states = new HashMap<String, String>();
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if(isChecked)
{
states.put(buttonView.getId(), buttonView..getText().toString());
} else
{
states.remove(buttonView.getId());
}
if(states.size() >= 5)
{
// Your Condition
// selectedStrings will now have all 5 checked CheckBox's Texts
List<String> selectedStrings = new ArrayList<String>(states.values());
}
}
Hope it helps.
Try out this one may be it will help you.
int checkBoxCounter = 0;
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked && checkBoxCounter<6){
// apply check and increment check counter
checkBoxCounter++;
}else{
//todo nothing
}
}
I am trying to make a popup window in an activity. The popup window shows up when we click a button in the activity. The layout for popup window is to show a radio group containing 4 radio buttons, a button and a seek bar and has to return a value to the main activity based on the selected radio button when the button in the pop up window is pressed.
When i run the app and open the pop up window it is giving we this error:
"java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.RadioGroup.setOnCheckedChangeListener(android.widget.RadioGroup$OnCheckedChangeListener)' on a null object reference "
The code for my main activity is:
public class CustomMenuActivity extends Activity
{
String ingredientName;
String ingredientQuantity;
private PopupWindow pw;
Button setQuantity;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_menu);
setQuantity = (Button) findViewById(R.id.btnSetQty);
setQuantity.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v)
{
initiatePopupWindow();
}
});
}
private void initiatePopupWindow()
{
try {
//We need to get the instance of the LayoutInflater, use the context of this activity
LayoutInflater inflater = (LayoutInflater) CustomMenuActivity.this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//Inflate the view from a predefined XML layout
View layout = inflater.inflate(R.layout.set_quantity_popup,
(ViewGroup) findViewById(R.id.popupElementid));
// create a 600px width and 570px height PopupWindow
pw = new PopupWindow(layout, 600, 570, true);
// display the popup in the center
pw.showAtLocation(layout, Gravity.CENTER, 0, 0);
RadioGroup radioGroup;
radioGroup = (RadioGroup) findViewById(R.id.radioGroupid);
final String[] tempQtyVar = new String[1];
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId){
case R.id.rbqty30id:
tempQtyVar[0] = "30";
break;
case R.id.rbqty60id:
tempQtyVar[0] = "60";
break;
case R.id.rbqty90id:
tempQtyVar[0] = "90";
break;
case R.id.rbqtycutomid:
tempQtyVar[0] = "120";
break;
}
}
});
Button setQtyBtn = (Button) layout.findViewById(R.id.buttonOkSetQtyid);
setQtyBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
ingredientQuantity = tempQtyVar[0];
Toast.makeText(getApplicationContext(),ingredientQuantity,Toast.LENGTH_LONG).show();
pw.dismiss();
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
The layout.xml for my pop up window is:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="#fd050505"
android:padding="30dp"
android:id="#+id/popupElementid">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:id="#+id/relativeLayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SET QUANTITY"
android:textColor="#84e9e6"
android:textSize="20sp"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:textStyle="bold"
android:id="#+id/popupTitleid"/>
<LinearLayout
android:layout_width="600dp"
android:layout_height="wrap_content"
android:layout_below="#+id/popupTitleid"
android:orientation="horizontal"
android:background="#drawable/btn_rounded_boarder"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp">
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/radioGroupid"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal"
>
<RadioButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=" 30ml "
android:textColor="#84e9e6"
android:id="#+id/rbqty30id"
android:checked="true" />
<RadioButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#84e9e6"
android:text=" 60ml "
android:id="#+id/rbqty60id" />
<RadioButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#84e9e6"
android:text=" 90ml "
android:id="#+id/rbqty90id" />
<RadioButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#84e9e6"
android:text=" Custom Value "
android:id="#+id/rbqtycutomid"
/>
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="600dp"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_centerHorizontal="true">
<SeekBar
android:id="#+id/customqtySBid"
android:layout_height="fill_parent"
android:layout_width="600dp"
android:textColor="#84e9e6"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="150dp"
android:paddingBottom="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/buttonOkSetQtyid"
android:textColor="#84e9e6"
android:text="OK"
android:background="#drawable/btn_rounded_boarder"
android:layout_marginTop="275dp"/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
I tried looking for answer online but didn't really find solution specific to my problem. Please suggest any solutions.
Thanks in advance.
You seem to be inflating the wrong layout. Change the correct layout.xml in
setContentView(R.layout.activity_custom_menu);
I am trying to make a radio button toggle using setChecked().
setChecked(false) works fine but setChecked(true) doesn't work.
Also tried toggle(), even this doesn't uncheck the radio button.
I need a solution without using radio groups. Just a single radio button and on tapping should toggle its state.
MainActivity.java
public void radioCheck(View v) {
System.out.println("radioCheck");
RadioButton rb = (RadioButton) findViewById(R.id.radioButton1);
//rb.toggle();
if (rb.isChecked() == true) {
rb.setChecked(false);
}
else {
rb.setChecked(true);
}
}
activity_main.xml
<RadioButton
android:id="#+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button1"
android:layout_centerHorizontal="true"
android:onClick="radioCheck"
android:text="Set me" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/radioButton1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="39dp"
android:onClick="radioCheck"
android:text="On/ Off" />
Surprisingly, setChecked works when a button is used to uncheck the radio button but the same doesn't work when set on radio button.
You're causing a infinite loop and stack overflow probably. The setChecked is all unnecessary, you don't need to toggle it yourself. The onClick is for reacting to a new selection, not checking/unchecking it yourself.
From http://developer.android.com/guide/topics/ui/controls/radiobutton.html:
<?xml version="1.0" encoding="utf-8"?>
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioButton android:id="#+id/radio_pirates"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/pirates"
android:onClick="onRadioButtonClicked"/>
<RadioButton android:id="#+id/radio_ninjas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/ninjas"
android:onClick="onRadioButtonClicked"/>
</RadioGroup>
public void onRadioButtonClicked(View view) {
// Is the button now checked?
boolean checked = ((RadioButton) view).isChecked();
// Check which radio button was clicked
switch(view.getId()) {
case R.id.radio_pirates:
if (checked)
// Pirates are the best
break;
case R.id.radio_ninjas:
if (checked)
// Ninjas rule
break;
}
}
Try this way,hope this will help you to solve your problem.
if condition work true or false case so when you get isChecked() is already return true or false so no required to check with (== true) this things you have done wrong in your code.
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<RadioButton
android:id="#+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Set me" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="radioCheck"
android:layout_marginTop="10dp"
android:text="On/ Off" />
</LinearLayout>
MainActivity.java
public class MainActivity extends Activity {
private RadioButton radioButton1;
private Button button2;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
radioButton1 = (RadioButton) findViewById(R.id.radioButton1);
button2 = (RadioButton) findViewById(R.id.button2);
}
public void radioCheck(View v) {
if (radioButton1.isChecked()) {
radioButton1.setChecked(false);
}
else {
radioButton1.setChecked(true);
}
}
}
How do I ensure that user is checked at least one radiobutton from each radiogroup. Like I have this radiogroup:
<RadioGroup
android:id="#+id/myradio_group_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="first"
android:checked="true" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="second" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="third" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fourt" />
</RadioGroup>
<RadioGroup
android:id="#+id/myradio_group_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="first"
android:checked="true" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="second" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="third" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fourt" />
</RadioGroup>
I want to check programmatically if user select at least one radiobutton or not?
Get a reference of the RadioGroup and then call getCheckedRadioButtonId() on the radio group if nothing is selected then the call will return -1.
See public int getCheckedRadioButtonId ()
RadioGroup g = (RadioGroup) findViewById(R.id.rBtnDigits);
// Returns an integer which represents the selected radio button's ID
int selected = g.getCheckedRadioButtonId();
// Gets a reference to our "selected" radio button
RadioButton b = (RadioButton) findViewById(selected);
// Now you can get the text or whatever you want from the "selected" radio button
b.getText();
if (radioGroup.getCheckedRadioButtonId() != -1)
{
// hurray at-least on radio button is checked.
}
else
{
// pls select at-least one radio button.. since id is -1 means no button is check
}
This is the code i have used in one of my quiz app.. Have a look at the code if this helps..
private boolean checkAnswer(){
String answer = getSelection();
if(answer==null) {
Log.d("Questions", "No checkbox selected");
return false;
}
else {
// Do your stuff here
return true;
}
}
private String getSelection(){
if (c1.isChecked())
{
return c1.getText().toString();
}
if (c2.isChecked())
{
return c2.getText().toString();
}
if (c3.isChecked())
{
return c3.getText().toString();
}
if (c4.isChecked())
{
return c4.getText().toString();
}
return null;
}
You can use this method
radioGroup.getCheckedRadioButtonId();
It returns the identifier of the selected radio button in this group. Upon empty selection, the returned value is -1.
As mentioned in the documentation https://developer.android.com/reference/android/widget/RadioGroup.html#getCheckedRadioButtonId()
I have a RadioGroup inside of which I have some RadioButtons.
I want to set some text on the RadioButtons programmatically. I used following code for that using that I'm unable to access the RadioButtons inside of the RadioGroup using Java.
How can I set the text on a RadioButton inside a RadioGroup?
XML Layout:
<RadioGroup android:layout_width="fill_parent"
android:layout_marginLeft="20dip"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/QueGroup1">
<RadioButton android:checked="false"
android:button="#drawable/green"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textColor="#000"
android:text="Yes"
android:id="#+id/rbtnYes"
android:visibility="gone" />
<RadioButton android:checked="false"
android:button="#drawable/red"
android:textColor="#000"
android:text="No"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="#+id/rbtnNo"
android:visibility="gone" />
<RadioButton android:checked="false"
android:button="#drawable/red"
android:textColor="#000"
android:text="Dont Know"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="#+id/rbtnDontKnow"
android:visibility="gone" />
</RadioGroup>
Java code:
private void fnRadioTextSet(String strval) {
rbtnYes = (RadioButton)findViewById(R.id.rbtnYes);
rbtnNo = (RadioButton)findViewById(R.id.rbtnNo);
rbtnDontKnow = (RadioButton)findViewById(R.id.rbtnDontKnow);
RadioGroup rbtnGrp = (RadioGroup)findViewById(R.id.QueGroup1);
String[] strArrtext = strval.split(",");
for (int intcount = 0; intcount < strArrtext.length; intcount++) {
rbtnGrp.getChildAt(intcount).settext("test");
}
//int i = rbtnGrp.getChildCount();
//Toast.makeText(getApplication(), rbtnGrp.getChildCount(),
// Toast.LENGTH_LONG).show();
/*String[] strtext = strval.split(",");
if (strtext.length > 0) {
}*/
}
private void fnRadioTextSet(String strval) {
RadioGroup rbtnGrp = (RadioGroup)findViewById(R.id.QueGroup1);
String[] strArrtext = strval.split(",");
for (int i = 0; i < rbtnGrp.getChildCount(); i++) {
((RadioButton) rbtnGrp.getChildAt(i)).setText(strArrtext[i]);
}
}
Don't need the loop
rbtnYes.settext("sdklfhjsdf");
rbtnNo.settext("test");
rbtnDontKnow.settext("test");