jeudi 29 juin 2017

Android - View, Checkboxes, TextViews not refreshing at Runtime

I'm new to Android, and I'm having a problem with checkboxes and textviews not refreshing at runtime. The TextView has to change color from light gray to a lighter gray, and the Checkbox has to change the custom drawable that it has from red to green. I have tried the detach and attach the fragment but it shuts down and maybe I don't know where to put the detach and attach in the fragment. I have tried invalidate() and requestLayout(), and it shuts down there too. I tried having them in onCreateView() and maybe I shouldn't put them there. I don't have an activity with my fragment. Here are the images that I need to change. What it has in the preview window is the green custom checkbox drawables but at runtime they are the red custom drawables which is what they were before I changed them to green, and the TextViews are a lighter gray in the preview window but they are a darker gray at Runtime which is what they were before.

Green checkbox custom drawable Red custom custom drawable

           <CheckBox
            android:id="@+id/chkStarted"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/start"
            android:layout_below="@+id/chkInProgess"
            android:gravity="top"
            android:padding="4dp"
            android:checked="true"
            android:enabled="false"
            android:layout_marginTop="10dp"
            android:button="@xml/custom_checkbox_green"/>

        <CheckBox
            android:id="@+id/chkDownloaded"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_below="@+id/chkStarted"
            android:text="@string/download"
            android:gravity="top"
            android:padding="4dp"
            android:checked="true"
            android:enabled="false"
            android:button="@xml/custom_checkbox_green"/>

The textviews are not changing colors either at runtime, and I have tried to refresh the layouts, but they're not refreshing at runtime. They are what they need to be in the preview window, but they are not what they're supposed to be at runtime. Any help would be much appreciated. Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire