Jhonycage
Jhonycage

Reputation: 849

OnCheckedChangeListener not working

I am trying to set an event listener for Radio group, but when debbugging never triggers the listener, why? this how I have set up the radio group in order to look the way as is shown in the picture attached and perhaps there may be a problem with it,enter image description here

in XML:

<RadioGroup
                        android:id="@+id/idchoice"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:background="@drawable/selectorevidence2"
                        android:orientation="horizontal"
                        android:padding="10dp">

                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="vertical">

                            <RadioButton
                                android:id="@+id/rb_cedula"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginRight="10dp"
                                android:text="@string/CC"
                                android:textColor="#8fb5e3" />

                            <RadioButton
                                android:id="@+id/rb_extranjeria"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginRight="10dp"
                                android:text="@string/CE"
                                android:textColor="#8fb5e3" />

                            <RadioButton
                                android:id="@+id/rb_nn"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginRight="10dp"
                                android:text="@string/NN"
                                android:textColor="#8fb5e3" />

                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="vertical">

                            <RadioButton
                                android:id="@+id/rb_nui"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginRight="10dp"
                                android:text="@string/NUI"
                                android:textColor="#8fb5e3" />

                            <RadioButton
                                android:id="@+id/rb_passport"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginRight="10dp"
                                android:text="@string/PA"
                                android:textColor="#8fb5e3" />

                            <RadioButton
                                android:id="@+id/rb_nodoc"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginRight="10dp"
                                android:text="@string/NODOC"
                                android:textColor="#8fb5e3" />

                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="vertical">

                            <RadioButton
                                android:id="@+id/rb_ti"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginRight="10dp"
                                android:text="@string/TI"
                                android:textColor="#8fb5e3" />
                        </LinearLayout>
                    </RadioGroup>

and now in my Fragment:

rg_IdChoice = (RadioGroup) view.findViewById(R.id.idchoice); rg_IdChoice.setOnCheckedChangeListener(onIdTypeListener);

and the listener:

RadioGroup.OnCheckedChangeListener onIdTypeListener = new 
RadioGroup.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(RadioGroup radioGroup, @IdRes int i) {
        rg_IdChoice.clearCheck();
        switch (i){
            case R.id.rb_cedula:

VicitmEviSelected.setDocType(IpatValues.DocType.getDocTypes(0));
                break;
            case R.id.rb_extranjeria:

VicitmEviSelected.setDocType(IpatValues.DocType.getDocTypes(1));
                break;
            case R.id.rb_nn:

VicitmEviSelected.setDocType(IpatValues.DocType.getDocTypes(2));
                break;
            case R.id.rb_nui:

VicitmEviSelected.setDocType(IpatValues.DocType.getDocTypes(3));
                break;
            case R.id.rb_passport:

VicitmEviSelected.setDocType(IpatValues.DocType.getDocTypes(4));
                break;
            case R.id.rb_nodoc:

VicitmEviSelected.setDocType(IpatValues.DocType.getDocTypes(5));
                break;
            case R.id.rb_ti:

VicitmEviSelected.setDocType(IpatValues.DocType.getDocTypes(6));
                break;
        }
    }
};

Can anybody see what am I doing wrong, any tips will be highly appreciated.

Upvotes: 0

Views: 297

Answers (0)

Related Questions