public void onPageSelected(int position) {}

方法中得到radiobutton时,最好通过(RadioButton) this.radioGroup.findViewById(position)来寻找;

但是前提是为radiogroup中的每一个radiobutton设置id,而且id是从0开始编号。

因为ViewPager的页号也是从0开始编址的。所以可以保持上下编号的一致。

public void onPageSelected(int position) {
        RadioButton button = (RadioButton) this.categoryGroup.findViewById(position);
        Log.e("now page", position+"");
        button.setChecked(true);
        
    }

public void onCheckedChanged(RadioGroup group, int checkedId) {
        Log.e("now check button", checkedId+"");
        this.newsViewPager.setCurrentItem(checkedId);
    }

viewpager 与 radiogroup 联动时的位置问题的更多相关文章

  1. 自定义ViewPager+RadioGroup联动效果的实现

    package com.loaderman.myviewpager; import android.os.Bundle; import android.support.v7.app.AppCompat ...

  2. 使用 ViewPager 和 RadioGroup 封装的一个导航控件

    import android.animation.ObjectAnimator; import android.content.Context; import android.graphics.dra ...

  3. sharepoint 2010 页面刷新时滚动条位置保持不变 Controlling scrollbar position on postback

    sharepoint 2010 页面刷新时滚动条位置保持不变 Controlling scrollbar position on postback在sharepoint 2010中,如果当前页面的篇幅 ...

  4. 页面跳转,A跳到B,B再返回A时自动定位到离开A时的位置

    <template> <div class="hello" @scroll="scrollLoad" id="myScrollBox ...

  5. #748 – 获得按下时对应位置点的大小(Getting the Size of a Contact Point during Raw Touch)

    原文:#748 – 获得按下时对应位置点的大小(Getting the Size of a Contact Point during Raw Touch) 原文地址:https://wpf.2000t ...

  6. TabLayout和ViewPager联动时的问题及解决方案

    问题概述 TabLayout搭配ViewPager关联使用时,在未调用TabLayout的setupWithViewPager(mViewPager)方法之前,ViewPager的内容和TabLayo ...

  7. input输入时光标位置靠上问题解决

    在css中如果我们定义了input高度在输入时会发现光标位置靠上了不在居中了,在Chrome浏览器中,当设置了line-height时,input无文字,光标高度与line-height一致:inpu ...

  8. vue在多级联动时,一些情况不用watch而用onchange会更好

    onchange事件在内容改变且失去焦点时触发,因此在一些多级联动需要清空次级内容的时候,用onchange就非常有用了,尤其是浏览器会提前加载数据的情况下.有篇文章可以看一下,链接. PS:路漫漫其 ...

  9. ViewPager中使用PhotoView时出现pointerIndex out of range异常

    问题描述: 当PhotoView 和 ViewPager 组合时 ,用双指进行放大时 是没有问题的,但是用双指进行缩小的时候,程序就会崩掉,并且抛出java.lang.IllegalArgumentE ...

随机推荐

  1. Android Programming: Pushing the Limits -- Chapter 4: Android User Experience and Interface Design

    User Stories Android UI Design 附加资源 User Stories: @.通过写故事来设计应用. @.每个故事只关注一件事. @.不同的故事可能使用相同的组件,因此尽早地 ...

  2. JS中级 - 02:表单、表格

    getElementsByTagName() getElementsByTagName() 方法可返回带有指定标签名的对象的集合. getElementsByClassName() 返回文档中所有指定 ...

  3. 与你相遇好幸运,Sails.js安装

    官网: http://sailsjs.org Github:https://github.com/balderdashy/sails 开发文档: http://sailsjs.org/document ...

  4. C# 根据ADO.NET数据库连接字符串构建EntityFrame数据库连接字符串

    为了保持开发效率,以及保持代码优雅,项目中引用了EntityFrame.但是又因为某些报表功能需要大量计算,所以又要求直接使用ADO.NET,调用存储过程进行计算. 于是乎webconfig文件中就会 ...

  5. 使用python递归子目录处理日志文件

    重要说明: (1)python使用4个空格进行层次缩进的(不是tab),在eclipse里面可以直接使用tab缩进,是因为eclipse会实时地将tab转成4个空格 (2)在eclipse中安装pyD ...

  6. 游戏主循环(Game Loop)

    游戏主循环是游戏的心跳,一般使用while循环进行主动刷新. 一次循环由获取用户输入.更新游戏状态.处理AI.播放音乐和绘制画面组成. 这些行为可以分成两类: update_game(); // 更新 ...

  7. hdu 4025 2011上海赛区网络赛E 压缩 ***

    直接T了,居然可以这么剪枝 题解链接:点我 #include<cstdio> #include<map> #include<cstring> #define ll ...

  8. Android数据缓存(转)

    Android数据缓存   1.http://blog.csdn.net/lnb333666/article/details/8460159 2.https://github.com/Trinea/a ...

  9. Codeforces Round #198 (Div. 1) D. Iahub and Xors 二维树状数组*

    D. Iahub and Xors   Iahub does not like background stories, so he'll tell you exactly what this prob ...

  10. C#分布式缓存Couchbase使用

    目前C#业界使用得最多的 Cache 系统主要是 Memcached和 Redis. 这两个 Cache 系统可以说是比较成熟的解决方案,也是很多系统当然的选择. 一.简介 目前C#业界使用得最多的 ...