I would to create a number of radio button dinamically in a fragment, I only have problem with style. If I put radiobutton code in the xml file, default style is applied correctly, but when I create radiobutton through a function I see different style!
XML
<RadioGroup
            android:id="@+id/radiogroup"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical"
            android:animationCache="false">
            <RadioButton
                android:text="RadioButton 1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/radioButton3" />
            <RadioButton
                android:text="RadioButton 2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/radioButton4" />
</RadioGroup>
RESULT
JAVA CODE
This code is put in onCreateView in the fragment
public void addRadioButton(Context ctx,int num){
    RadioGroup radioGroup= (RadioGroup) alertInflatedView.findViewById(R.id.radiogroup);
    for (int i = 1; i <= num; i++) {
        RadioButton radioButton  = new RadioButton(ctx);
        radioButton.setId(1+i);
        radioButton.setText("Radio " + radioButton.getId());
        radioButton.setTextColor(getResources().getColor(R.color.black));
        radioGroup.addView(radioButton);
    }
}
RESULT
As you can see radio buttons have different style, someone could help me, if is possibile, to apply default style programmatically?


 
     
     
    