Mutually exclusive Radio Button: How to define a custom ListView with multiple elements accompany with a radio button a
By : Akhil K.R
Date : March 29 2020, 07:55 AM
|
How to get the text from radio button in a radio group when radio button checked state is changed
By : Juan Mora Romero
Date : March 29 2020, 07:55 AM
Does that help I have created two radio buttons in a radio group dynamically and one of them is checked. I need when i cheked another button then its value should be saved in string. But i have implemented checkedchangelistener for this.But its not working first time. Here is my code. , xml file code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RadioGroup
android:id="@+id/radioSex"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radioMale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/radio_male"
android:checked="true" />
<RadioButton
android:id="@+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/radio_female" />
</RadioGroup>
<Button
android:id="@+id/btnDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_display" />
</LinearLayout>
package com.mkyong.android;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
public class MyAndroidAppActivity extends Activity {
private RadioGroup radioSexGroup;
private RadioButton radioSexButton;
private Button btnDisplay;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
addListenerOnButton();
}
public void addListenerOnButton() {
radioSexGroup = (RadioGroup) findViewById(R.id.radioSex);
btnDisplay = (Button) findViewById(R.id.btnDisplay);
btnDisplay.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// get selected radio button from radioGroup
int selectedId = radioSexGroup.getCheckedRadioButtonId();
// find the radiobutton by returned id
radioSexButton = (RadioButton) findViewById(selectedId);
Toast.makeText(MyAndroidAppActivity.this,
radioSexButton.getText(), Toast.LENGTH_SHORT).show();
}
});
}
}
|
In radio group Selecting radio button as yes must enable a textview & selecting radio button as no must disable text
By : Hyeri Lee
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further In radio group Selecting radio button as YES must enable a textview & selecting radio button as NO must disable textview in android. code :
class MainActivity extends Activity {
RadioGroup rad;
TextView q6;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
q6=(TextView) findViewById(R.id.q6);
rad=(RadioGroup) findViewById(R.id.rg5);
rad.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
int id=rad.getCheckedRadioButtonId();
View radioButton = rad.findViewById(id);
if(radioButton.getId()==R.id.rg5r1)
{
q6.setEnabled(false);
}
else
{
q6.setEnabled(true);
}
}
});
}
|
Handler for checking radio button based on another input field stops working after unchecking radio button from another
By : mutley
Date : March 29 2020, 07:55 AM
|
Radio button in angular js select only first radio button no other radio button is selected
By : Berradi Fouâd
Date : March 29 2020, 07:55 AM
|