安卓开发通过ViewPage和RadioButton+SharedPreferences实现欢迎页

来源:互联网 发布:sqlserver 服务器名称 编辑:程序博客网 时间:2024/07/24 00:54

新手上路,各位大佬帮忙改错啊


之前看了很多欢迎页的例子,自己研究了好久,做了一个,结合了大佬的资源,做了一个。各位前辈帮忙提意见
private void initView() {    //初始化单选按钮    ra = (RadioGroup) findViewById(R.id.group);    radio1 = (RadioButton) findViewById(R.id.ra1);    radio2 = (RadioButton) findViewById(R.id.ra2);    radio3 = (RadioButton) findViewById(R.id.ra3);    viewPager = (ViewPager) findViewById(R.id.viewPager);    listview = new ArrayList<>();    View v1 = getLayoutInflater().inflate(R.layout.tab1, null);    View v2 = getLayoutInflater().inflate(R.layout.tab2, null);    View v3 = getLayoutInflater().inflate(R.layout.tab3, null);    listview.add(v1);    listview.add(v2);    listview.add(v3);    myAdapter = new MyAdapter(listview);    viewPager.setAdapter(myAdapter);    //新的监听事件   viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {       @Override       public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {       }       @Override       public void onPageSelected(int position) {           switch (position) {               case 0:                   radio1.setChecked(true);                   radio2.setChecked(false);                   radio3.setChecked(false);                   break;               case 1:                   radio1.setChecked(false);                   radio2.setChecked(true);                   radio3.setChecked(false);                   break;               case 2:                   radio1.setChecked(false);                   radio2.setChecked(false);                   radio3.setChecked(true);                   break;           }       }       public void onPageScrollStateChanged(int state) {       }   });



0 0
原创粉丝点击