Android Question anotherdatepicker in customlayoutdialog

Discussion in 'Android Questions' started by Kiran Raotole, Sep 24, 2018.

  1. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    Hii,
    Another datepicker in Dialog.
    I'm trying to add anotherdatepicker in CustomLayoutDialog.
    Its shows Log

    Code:
    Error occurred on line: 150 (AnotherDatePicker)
    java.lang.RuntimeException: Object should first be initialized (B4XView).
        at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:
    50)
        at anywheresoftware.b4a.objects.B4XViewWrapper.getViewObject(B4XViewWrapper.java:
    81)
        at anywheresoftware.b4a.objects.B4XViewWrapper.getColor(B4XViewWrapper.java:
    360)
        at ctron.m4741.anotherdatepicker._datefield_textchanged(anotherdatepicker.java:
    562)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.shell.Shell.runMethod(
    Shell.java:733)
        at anywheresoftware.b4a.shell.Shell.raiseEventImpl(
    Shell.java:355)
        at anywheresoftware.b4a.shell.Shell.raiseEvent(
    Shell.java:255)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    144)
        at anywheresoftware.b4a.objects.EditTextWrapper$
    1.afterTextChanged(EditTextWrapper.java:83)
        at android.widget.TextView.sendAfterTextChanged(
    TextView.java:9380)
        at android.widget.TextView.setText(
    TextView.java:5403)
        at android.widget.TextView.setText(
    TextView.java:5250)
        at android.widget.EditText.setText(
    EditText.java:113)
        at android.widget.TextView.setText(
    TextView.java:5207)
        at android.widget.TextView.setTransformationMethod(
    TextView.java:2524)
        at android.widget.TextView.applySingleLine(
    TextView.java:9061)
        at android.widget.TextView.setSingleLine(
    TextView.java:9035)
        at anywheresoftware.b4a.objects.EditTextWrapper.setSingleLine(EditTextWrapper.java:
    140)
        at ctron.m4741.anotherdatepicker$ResumableSub_DesignerCreateView.resume(anotherdatepicker.java:
    742)
        at ctron.m4741.anotherdatepicker._designercreateview(anotherdatepicker.java:
    685)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.shell.Shell.runMethod(
    Shell.java:733)
        at anywheresoftware.b4a.shell.Shell.raiseEventImpl(
    Shell.java:355)
        at anywheresoftware.b4a.shell.Shell.raiseEvent(
    Shell.java:255)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    144)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    175)
        at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:
    61)
        at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:
    162)
        at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:
    134)
        at ctron.m4741.m51$ResumableSub_bcmd1_Click.resume(m51.java:
    434)
        at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:
    48)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.shell.Shell.runMethod(
    Shell.java:733)
        at anywheresoftware.b4a.shell.Shell.raiseEventImpl(
    Shell.java:355)
        at anywheresoftware.b4a.shell.Shell.raiseEvent(
    Shell.java:255)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    144)
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:
    171)
        at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:
    43)
        at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:
    245)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    137)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    175)
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:
    171)
        at anywheresoftware.b4a.agraham.dialogs.InputDialog$ExtendedBALayout$
    1.run(InputDialog.java:2467)
        at android.os.Handler.handleCallback(Handler.java:
    790)
        at android.os.Handler.dispatchMessage(Handler.java:
    99)
        at android.os.Looper.loop(Looper.java:
    172)
        at android.app.ActivityThread.main(ActivityThread.java:
    6590)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:
    438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    807)
    I attach my program file.
     

    Attached Files:

  2. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    The issue seems to be that the DateField_TextChanged event is being raised before DateField is initialized. If you put a Sleep(0) after the DateField = df statement (line 82) it fixes it, but you get:

    in the log window - so I think you need to look a bit closer at how that code works. Also, the date picker dialog doesn't display correctly, but that's probably because you've set the dialog height to 100dip.

    - Colin.
     
  3. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    I change height to 90%y, Its showing it, but datepicker layout is open behind dialog.
     
  4. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    Attached Files:

  5. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    how to do this?
     
  6. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    Dialogs are always in front. Another option would be to have a hidden panel that acts as a dialog & shows when you tap the button.

    - Colin.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice