Android Question AnotherDatePicker and Label not enable

sirjo66

Well-Known Member
Licensed User
Longtime User
Hello to all,

I'm using AnotherDatePicker class, and in my layout I have a DatePickerLabel and other objects.

If the customer has click on the DatePickerLabel, the DatePicker open and the customer can select a date.

But how can I disable it, so if the customer has click on DatePickerLabel the DatePicker don't open ??

In some situation I want to fix to a date, so I call
B4X:
TheDate.SetDate(DateTime.now, True)
but I don't want that the customer can change it, so I need a
B4X:
TheDate.Enabled = False

How can do it ??

Thanks
Sergio
 

sirjo66

Well-Known Member
Licensed User
Longtime User
Hi,
I'm try to change targetLabel to Public,
so I have change then line
Private targetLabel As Label
into
Public targetLabel As Label

Then, on Create event I have add:
B4X:
TheDate.targetLabel.Enabled = False

but...
B4X:
** Activity (addmod) Create, isFirst = true **
java.lang.RuntimeException: Object should first be initialized (Label).
   at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:46)
   at anywheresoftware.b4a.objects.ViewWrapper.setEnabled(ViewWrapper.java:217)
   at sjs.track.addmod._activity_create(addmod.java:374)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
   at sjs.track.addmod.afterFirstLayout(addmod.java:98)
   at sjs.track.addmod.access$100(addmod.java:16)
   at sjs.track.addmod$WaitForLayout.run(addmod.java:76)
   at android.os.Handler.handleCallback(Handler.java:615)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4867)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
   at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Object should first be initialized (Label).
Object context is paused. Ignoring CallSubDelayed: AddToActivity
Object context is paused. Ignoring CallSubDelayed: AddToActivity

Thanks for the help
Sergio
 
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
Thanks Erel,
I have solved !!

I have only add this SUB to AnotherDatePicker class and all is perfect !!
B4X:
Public Sub EnableDisable(Enabled As Boolean)
   If waitForAddToActivity Then
     CallSubDelayed2(Me, "EnableDisable", Enabled)
     Return
   End If
   targetLabel.Enabled = Enabled
End Sub

If you want, add this SUB also to your source and change version to 1.12 :cool:

Sergio
 
Upvote 0
Top