0

I'm creating a new Dialog view in Droid platform, using the CrossUI.Droid.Dialog project. I'm also using bindings provided by the MvvmCross Framework.

Here is the code I have in the Droid view, to create and bind the Dialog:

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        DroidResources.Initialise(typeof(Resource.Layout));

        Root = new RootElement()
            {
                new Section("Private Configuration")
                    {
                        new EntryElement("Name:").Bind(this, "{'Value':{'Path':'Configuration.Name'}}"),
                        new EntryElement("Description:").Bind(this, "{'Value':{'Path':'Configuration.PrivateDescription'}}"),
                        new BooleanElement("Active?").Bind(this, "{'Value':{'Path':'Configuration.Active'}}")
                    },
                new Section("Display Configuration")
                    {
                        new StringElement("Header Title")
                            {
                                Click = (o, e) => GoToHeaderTitleActivity(),
                                LayoutName = "dialog_rootNavigate"
                            }
                    }
            };
    }

When I run the app, the dialog is shown and the bindings are correct.

The problem I have is when I try to write something in one of the EntryElement, the focus just goes somewhere else... This only happens when I have 'Text Prediction' enabled.

I've checked the sample in Android.Dialog and all seems to work just fine.

I'm using a Galaxy Tab 2 7.0, with ICS 4.0

Does anyone had this problem?

zleao
  • 445
  • 3
  • 12
  • "Does anyone had this problem?" is not a very good question for StackOverflow - it's better to ask "How can I stop the TextView from losing focus?". Also I'm not sure this problem is to do with mvvmcross or Dialog - looks like it's more to with TextView's in general - maybe better asking this as a question about Android TextViews rather than as something as specialised as "mvvmcross" and "android-dialog". e.g. "I've got an Android TextView in one case that loses focus, how can I stop it happening?" Good luck! – Stuart Jan 18 '13 at 12:36
  • I am getting the exact same issue. Did you find a fix? –  Dec 29 '13 at 18:13
  • I've added some debugging to the droid.dialog stuff and this is what happens when you try to select a TextEdit: https://gist.github.com/wayne-o/8179431 I guess that is why we are losing focus? –  Dec 30 '13 at 08:36
  • And I can confirm that this does not happen when you select a text edit on the touch dialog. –  Dec 30 '13 at 09:10
  • I can also confirm this happens on the Sony Experia E and my HTC sensation. On GenyMotion (and i'm guessing the emulator) it does still happen but the text view doesn't lose focus - I'm guessing because it has the resources to handle all the getview calls and not lose track? I don't know for sure but this makes the droid.dialog stuff pretty unusable. I am trying to find a fix but if anyone can chip in I'd be really grateful. –  Dec 30 '13 at 09:19

1 Answers1

0

Found the answer!!

Apparently there is a known issue in Android where EditText controls and ListView don't play nice. This is not a problem with MvvmCross or Monodroid.Dialog.

To overcome this (and I'm guessing this is the reason for it's existence?) use the MvxLinearDialogActivity when developing forms using dialog. The issue instantly disappears.

As the comment in the class says:

DialogActivity based on a linear view, this will solve all edittext related focus problems when using elements suggestions at Focusable EditText inside ListView doesn't help for example

Community
  • 1
  • 1