检查onCheckedChanged调用用户输入而不是设备旋转 [英] Check if onCheckedChanged called by user input and not device rotate

查看:113
本文介绍了检查onCheckedChanged调用用户输入而不是设备旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有同样的问题作为<一个href="http://stackoverflow.com/questions/10647001/radiogroup-behavior-on-orientation-change">this没有答案的问题

I am having the same issue as this unanswered question

我的问题是:

有没有办法找出如果onCheckedChanged方法由用户输入(具体用户选择一个单选按钮选项的),或者如果它被称为是由于设备旋转?

Is there a way to find out if the onCheckedChanged method is called by user input (specifically the user selecting a radio button option) or if it is being called due to device rotation?

谢谢

推荐答案

哈利路亚!

这部作品

public void onCheckedChanged(RadioGroup group, int checkedId) {

    if (group.findViewById(checkedId).isPressed()) {
       //This will only execute if pressed. not if device rotates
    }

}

这篇关于检查onCheckedChanged调用用户输入而不是设备旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆