RadioGroupのgetCheckedRadioButtonId()メソッド



Radiogroups Getcheckedradiobuttonid Method



RadioGroupのgetCheckedRadioButtonId()メソッドが正しいIDを取得できません

ラジオボタンは、プロジェクトでよく使用されます。選択したアイテムのIDを取得するためにBaiduで使用されるgetCheckedRadioButtonId()メソッドですが、繰り返し開くと、比較的大きな数字の文字列が取得されます。最初は戸惑いましたが、百度には色々な百度が出てきませんでした。その後、一連の数字を見て、問題があると感じ(当時の考えがわからなかった)、3より大きいかどうかを判断しました(1つの選択肢は3でした)。サイクル-3に進み、最後に正しいIDを取得します。

//Get the currently selected item id selectId = radioGroup.getCheckedRadioButtonId() //If it is -1 then nothing is selected if (selectId == -1) { return } //id will get n times of all selected items + id of selected item while (selectId > 3) { selectId = selectId % 3//Divide the remainder to get the real id }

減算カードを使用してください。数字の文字列が大きすぎます