xamarin forms standard
look like a bug to me and I wonder how to bypass that..
[1]
on some devices the app crash when editor control got focus right after showing the keyboard.
[2]
(on my device) crashes after the clicking the done/next button when on landscape mode.
the error log in bellow.
so for [2] I tried to bypass that by:
having the editor int a frame parent control as so:
<Frame x:Name="frameEditor" IsTabStop="True" >
<Editor Margin="10"
x:Name="txtMemoriam"
HorizontalOptions="FillAndExpand"
AutoSize="TextChanges"
Placeholder="Memoriam"
Parent="frameEditor"
Completed="TxtMemoriam_Completed"
Focused="TxtMemoriam_Focused"
></Editor>
</Frame>
so now: on landscape mode the "done" button change to "next" control...
and apparently, its give focus to DatePicker control (open the datepicker)... (it's unexpected Behavior but it prevents it from crashing...)
for the first issue, I have tried to set focus.. but i dont yet know if its working - cause its not crashing on my device (got the report from google play)..
private void TxtMemoriam_Completed(object sender, EventArgs e)
{
//txtMemoriam.Unfocus();
//frameEditor.Focus();
Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
{
Task.Delay(1).ContinueWith(x => { this.txtMemoriam.Focus(); });
Task.Delay(10).ContinueWith(x => { this.txtMemoriam.Focus(); });
Task.Delay(100).ContinueWith(x => { this.txtMemoriam.Focus(); });
Task.Delay(1000).ContinueWith(x => { this.txtMemoriam.Focus(); });
});
}
private void TxtMemoriam_Focused(object sender, Xamarin.Forms.FocusEventArgs e)
{
this.txtMemoriam.Focus();
Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
{
Task.Delay(1).ContinueWith(x => { this.txtMemoriam.Focus(); });
Task.Delay(10).ContinueWith(x => { this.txtMemoriam.Focus(); });
Task.Delay(100).ContinueWith(x => { this.txtMemoriam.Focus(); });
Task.Delay(1000).ContinueWith(x => { this.txtMemoriam.Focus(); });
});
}
Issue: java.lang.IllegalStateException: focus search returned a view that wasn't able to take focus!
FATAL EXCEPTION: main
Process: com.shaot.nosafot, PID: 14496
java.lang.IllegalStateException: focus search returned a view that wasn't able to take focus!
at android.widget.TextView.onKeyUp(TextView.java:6674)
at android.view.KeyEvent.dispatch(KeyEvent.java:2766)
at android.view.View.dispatchKeyEvent(View.java:9948)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.widget.ScrollView.dispatchKeyEvent(ScrollView.java:391)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:439)
at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1861)
at android.support.v4.view.KeyEventDispatcher.activitySuperDispatchKeyEventPre28(KeyEventDispatcher.java:130)
at android.support.v4.view.KeyEventDispatcher.dispatchKeyEvent(KeyEventDispatcher.java:87)
at android.support.v4.app.SupportActivity.dispatchKeyEvent(ComponentActivity.java:126)
at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:535)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:59)
at android.support.v7.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchKeyEvent(AppCompatDelegateImpl.java:2533)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:59)
at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:353)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4736)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4707)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4244)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4297)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4263)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4390)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4271)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4447)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4244)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4297)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4263)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4271)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4244)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6671)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6645)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6606)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3915)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6524)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)