Can't Set the Text Property of Editor on Android

CihanCilCihanCil TRMember ✭✭

On my Xamarin.Forms PLC project, I try to set Text property of an Entry. When I run it on iOS, works fine but on Android I can't see the text I set.

Maybe it is something about Entry renderer for Android?

Posts

  • PaulDistonPaulDiston USUniversity ✭✭✭✭

    Are you using your own renderer or the built in one?

  • CihanCilCihanCil TRMember ✭✭
    edited July 2014
    public class MainPage : ContentPage
    {
            public MainPage()
            {
                var editor = new Editor ();
                editor.Text = "Some Text...";
                Content = editor;
            }
    }
    

    They are all built in. The code above is a simplest example. When I try this on iOS it works as expected. But on Android only a blank Editor appears.

  • rmarinhormarinho PTMember, Insider, Beta Xamurai

    it should work, can u try put it inside a stacklayout panel and maybe give some WidthRequest and heightrequest to the editor to see if it works..

  • CihanCilCihanCil TRMember ✭✭

    @rmarinho‌
    I already did that. Same result :(

    Could anybody try it on their setup? If you guys can not set the Text on Android as well, it should be a bug then, right?

  • StephaneDelcroixStephaneDelcroix USInsider, Beta ✭✭✭✭

    Are you sure there's no Text. Or it's just that you can't see it ? try setting the Editor BackgroundColor to create some contrast... my .02€

  • CihanCilCihanCil TRMember ✭✭

    @StephaneDelcroix‌

    After the app runs on my emulator, I can enter some text with keyboard and I can see the text. Background or Text Colors are not the reason behind. I don't know why but I can't set Text of Editor on Android.

    By the way, I realized that I have written Entry at my first post. I meant Editor, not Entry. Nothings wrong with Entry.

  • BrianMBrianM USMember ✭✭

    I have the same problem. It works on iOS, but not on Android. I have my Editor in a StackPanel.

  • CihanCilCihanCil TRMember ✭✭
    edited July 2014
    using System;
    using Xamarin.Forms;
    
    namespace FormsGallery
    {
        class EditorDemoPage : ContentPage
        {
            public EditorDemoPage()
            {
                Label header = new Label
                {
                    Text = "Editor",
                    Font = Font.BoldSystemFontOfSize(50),
                    HorizontalOptions = LayoutOptions.Center
                };
    
                Editor editor = new Editor
                {
                    VerticalOptions = LayoutOptions.FillAndExpand
                };
    
                // Accomodate iPhone status bar.
                this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
    
                // Build the page.
                this.Content = new StackLayout
                {
                    Children = 
                    {
                        header,
                        editor
                    }
                };
            }
        }
    }
    

    This is from a sample project called FormsGallery. I run this project on my Android emulator and get the same result: Blank Editor.

    It must be a bug. Do I miss something?

  • StephaneDelcroixStephaneDelcroix USInsider, Beta ✭✭✭✭

    thanks for the report. I'm filing this for further investigation

  • JasperFredricksonJasperFredrickson USMember
    edited July 2014

    This is a total hack, but after the initial clear I reset the text and it shows up fine for me.

    var InitialValue = "Test"; var StopClearing = true; var myEditor = new Editor(); myEditor.Text = InitialValue; myEditor.TextChanged += (o, e) => { if (e.NewTextValue == "" && StopClearing && Device.OnPlatform(false, true, false)) { myEditor.Text = InitialValue; StopClearing = false; } };

  • Hi, with a Shared project and 1.2.1, I do see the text in the Entry.
    The entry is contained by a StackLayout (vertical) which is contained by a Scrollview. Maybe this does the difference?

  • CihanCilCihanCil TRMember ✭✭

    It's fixed with 1.2.1

  • Same issue on UWP.
    It works fine on Android.

Sign In or Register to comment.