m umer
m umer

Reputation: 11

get total number of radio button in radio group android

I have a dynamic set of radio button in a radio group and I want the total number of button present in it. In this particular case, I have two radio button but how can I get the count of two?

                    for (int i = 0; i < listArray.length; i++) {
                       
                        rb = new RadioButton(this);
                        rb.setId(i);
                        rb.setTextColor(this.getResources().getColor(R.color.white));
                        rb.setText(i);
                      

                        rg.addView(rb, layoutParams);
                    }

Upvotes: 0

Views: 263

Answers (1)

Per.J
Per.J

Reputation: 1388

You could use rg.getChildCount();

Upvotes: 2

Related Questions