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()
.
精彩评论