This is actually very simple.
Get a link to RadioGroupand DatePicker. Contribute OnCheckedChangeListenerfor RadioGroupand check where it was marked RadioButton.
RadioButton A, DatePicker , RadioButton B, gone invisible .
.
public class MyActivity extends Activity {
private RadioGroup choice;
private DatePicker datePicker;
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.your_layout);
choice = (RadioGroup) findViewById(R.id.choice);
datePicker = (DatePicker) findViewById(R.id.date_picker);
choice.setOnCheckedChangeListener(
new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch(checkedId) {
case R.id.radio_button_a:
datePicker.setVisibility(View.VISIBLE);
break;
case R.id.radio_button_b:
datePicker.setVisibility(View.GONE);
break;
}
}
});
}
}
- .