question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RadioButtons seem to lose their Text when clicked

See original GitHub issue

Describe the bug RadioButtons initially display their Text, but the text disappears when clicked. This was not a problem in previous versions (I was previously using 2.3.6), but after upgrading to 3.0.4 this seems to be happening, so it maybe was introduced recently.

To Reproduce

The following code reproduced the problem for me:

var stackLayout = new StackLayout();
this.Content = stackLayout;

var group = new RadioButtonGroupView();
stackLayout.Children.Add(group);

var firstRadio = new RadioButton();
firstRadio.Text = "First";
group.Children.Add(firstRadio);

var secondRadio = new RadioButton();
secondRadio.Text = "Second";
group.Children.Add(secondRadio);

Expected behavior The radio buttons should continue to display “First” and “Second” after being clicked.

Screenshots 2019-03-27_14-19-13

Desktop (please complete the following information): Not tested on desktop.

Smartphone (please complete the following information):

  • Device: Android Emulator
  • OS: 8.0 (Oreo)
  • Version: InputKit version 3.0.4

Additional context As mentioned above, I think this might be a new bug caused some point between 2.3.6 and 3.0.4, but I haven’t upgraded frequently enough to know exactly where.

Thanks so much for this great library!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
enisncommented, Mar 27, 2019

https://github.com/enisn/Xamarin.Forms.InputKit/blob/master/InputKit/Shared/Controls/RadioButton.cs#L253

As I see, default value of TextColor returns Transparent. I’m working on it 👍.

Until I update, can you try set a TextColor like Black or something else?

1reaction
vchelarucommented, Apr 6, 2019

If I explicitly set the TextColor to Black then all works okay:

var firstRadio = new RadioButton();
firstRadio.TextColor = Color.Black; // <- This fixes it...
firstRadio.Text = "First";
firstRadio.Value = Values.First;
group.Children.Add(firstRadio);


var secondRadio = new RadioButton();
secondRadio.TextColor = Color.Black; // <- And this also fixes it...
secondRadio.Text = "second";
secondRadio.Value = Values.Second;
group.Children.Add(secondRadio);

I don’t know enough about how styles.xml works to know if something is overridden there. But I don’t think there’s anything there that could impact this:

<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
      <item name="android:windowNoTitle">false</item>
    </style>

    <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@drawable/background_splash</item>
    </style>

</resources>

Anyway, the workaround of setting the text color is good enough for me because I plan on doing that anyway. Not sure if it’s worth keeping this open at this point or not if it doesn’t reproduce for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Radio button answer appears in <textarea> but then ...
Project: create 4 radio buttons; user clicks on an option and submits; answer should appear in a textarea box. Why is it when...
Read more >
Custom radio buttons not triggering a lost focus on click
The only way to get it to lose focus is via the tab key or clicking directly into a different text box. 35%20PM....
Read more >
Radio button loses initial 'IsChecked=True' value when ...
Initial thoughts are that it appears that all the radio buttons on the view are treated as one group (tried to give the...
Read more >
Display dependant text only when a form radio button is ...
I am working a form and it has several questions that contain yes/no option buttons. What I would like to do is when...
Read more >
Radio buttons on a sheet, and font/text size changing
When the user clicks one of the radio buttons, the font size (or maybe more exactly, the text size) appears to change.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found