Android-RadioGroup-onCheckedChangeListener
RadioGroup在做底部Tab栏时,需要监听选中项目,并设定主显示区ViewPager的当前页面
false:的作用是禁用左右滑动;
方法:
1 rgGroup.setOnCheckedChangeListeener(new OnCheckedChangeListener() { 2 3 @Override 4 public void onCheckedChanged(RadioGroup group, int checkedId) { 5 switch (checkedId) { 6 case R.id.rb_home: 7 mViewPager.setCurrentItem(0, false); 8 break; 9 case R.id.rb_news: 10 mViewPager.setCurrentItem(0, false); 11 break; 12 case R.id.rb_smart: 13 mViewPager.setCurrentItem(0, false); 14 break; 15 case R.id.rb_gov: 16 mViewPager.setCurrentItem(0, false); 17 break; 18 case R.id.rb_setting: 19 mViewPager.setCurrentItem(0, false); 20 break; 21 default: 22 break; 23 } 24 } 25 });