开发者

What is 'focus' within the Android API?

开发者 https://www.devze.com 2023-02-02 03:56 出处:网络
Simple question, but I can\'t seem to find a good answer within the Android docs. What exactly does it mean when a view has focus?

Simple question, but I can't seem to find a good answer within the Android docs. What exactly does it mean when a view has focus?

More specifically, if using a RadioGroup, can I access the selected child RadioButton by using something like the following?

RadioGroup rg = (RadioGroup) findViewById(radiogroup);
RadioButton activeChild = rg.getFocusedChild();
开发者_JAVA技巧

My thought was that this would not work... so I started to investigate exactly what focus was. But alas, I've been unsuccessful.


You want to get the selected child, not the focused child. Focus in Android refers to a mode that's only used for dpad/trackball selection. You probably want getCheckedRadioButtonId().

0

精彩评论

暂无评论...
验证码 换一张
取 消