try to use this
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<RadioButton
android:id="@+id/standard_delivery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Standard_delivery"
android:checked="true"
android:layout_marginTop="4dp"
android:layout_marginLeft="15dp"
android:textSize="12dp"
android:onClick="onRadioButtonClicked"
/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Midnight_delivery"
android:checked="false"
android:layout_marginRight="15dp"
android:layout_marginTop="4dp"
android:textSize="12dp"
android:onClick="onRadioButtonClicked"
android:id="@+id/midnight_delivery"
/>
</RadioGroup>
this is java class
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.standard_delivery:
if (checked)
Toast.makeText(DishActivity.this," standard delivery",Toast.LENGTH_LONG).show();
break;
case R.id.midnight_delivery:
if (checked)
Toast.makeText(DishActivity.this," midnight delivery",Toast.LENGTH_LONG).show();
break;
}
}