I am setting different RadioGroup like this:

fragment.setT1RadioGroup((RadioGroup)fragView.findViewById(rowids[0]).findViewById(R.id.t1_radiogroup));


For refactoring purpose could I reduce the size of this code? How?

• Show us your code for whatever the fragment object is. In what way is the fragment.setT1RadioGroup different from fragment.setT2RadioGroup? – Simon Forsberg Jan 17 '14 at 13:03

Assuming that setT5RadioGroup only sets a variable within the fragment:

In your fragment, use RadioGroup[] radioGroups = new RadioGroup[10];

setTRadioGroup(int number, RadioGroup grp) {

for (int i = 0; i < rowids.length; i++) { // assuming rowids.length is 10

Whenever you find yourself using multiple numbered methods that does very similar things, think: Array!! (or possibly List<ElementType> if you want to be able to add/remove dynamically)