Just an improvement to the nice answer given by @vuhung3990. I implemented the solution and works great but if I touch one radio button it will be selected and nothing happens.
I suggest to also change page when a radio button is tapped. To do this, simply add a listener to the radioGroup:
mPager = (ViewPager) findViewById(R.id.pager);
final RadioGroup radioGroup = (RadioGroup)findViewById(R.id.radiogroup);
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.radioButton :
mPager.setCurrentItem(0, true);
break;
case R.id.radioButton2 :
mPager.setCurrentItem(1, true);
break;
case R.id.radioButton3 :
mPager.setCurrentItem(2, true);
break;
}
}
});