I have a radio group and in this radio group i have two radio buttons. I want make this radio button non-clickable for particular user. Please help me.
installation_Satisfactory=(RadioGroup)findViewById(R.id.installation_satisfactory);
if (roleID==19)
{
for(int i = 0; i < installation_Satisfactory.getChildCount(); i++){
((RadioButton)installation_Satisfactory.getChildAt(i)).setEnabled(false);
}
}
I have tried this code and my role id is im using for particular user for that i want this radio button non-clickable. But if i'm not using role id it disabled for all users. but i want for particular user. Please help me
if(Integer.parseInt(viewInspectionSheetModel.getInstallationSatisfactory())==1)
installation_Satisfactory.check(R.id.installation_yes);
if(Integer.parseInt(viewInspectionSheetModel.getInstallationSatisfactory())==0)
installation_Satisfactory.check(R.id.installation_no);
while i am using property setOnCheckedChangeListener (false) is showing error like can't use false in boolean. so please help me
Use both if and else for your case to solve your isssue.
if (roleID==19)
{
for(int i = 0; i < installation_Satisfactory.getChildCount(); i++){
((RadioButton)installation_Satisfactory.getChildAt(i)).setEnabled(false);
} else
{
for(int i = 0; i < installation_Satisfactory.getChildCount(); i++){
((RadioButton)installation_Satisfactory.getChildAt(i)).setEnabled(true);
}
you can try this
radioButton1.setEnabled(false);
radioButton2.setEnabled(true);
int RoleID =19;
RadioGroup radioSexGroup = (RadioGroup) findViewById(R.id.radioSex);
radioSexGroup.getChildCount();
for(int i=0;i<radioSexGroup.getChildCount();i++)
{
RadioButton radioButton = (RadioButton)radioSexGroup.getChildAt(i);
if(RoleID==19)
{
if(radioButton.getId() == R.id.installation_satisfactory)
{
radioButton.setEnabled(false);
}
}
}
xml :
<RadioGroup
android:id="@+id/radioSex"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/installation_satisfactory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="male"
/>
<RadioButton
android:id="@+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="female" />
</RadioGroup>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.