开发者

What is 'focus' within the Android API?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜