Android Question Widget and Page for edit

Artur2024

Member
Hey :)
I'm still studying.
I used it Android Tutorial Widget Layout (Resizable, Adaptive)
after modification, it displayed the number of days from the date (Widget_4x1.bas, line 21). By clicking on Label, I would like to change the date. I can't open the date change window.

1636721415621.png


I need help with how to display the date to be changed (it's not about saving).

I greet arthur
 

Attachments

  • Widget Test.zip
    135.3 KB · Views: 145

Erel

B4X founder
Staff member
Licensed User
Longtime User
how can I open B4XPages by clicking on the widget?
You can call StartActivity(Main), however on Android 10+, starting an activity from a service is only possible with the special "draw over apps" permission (I haven't tested it with widgets so there might be a special case here).
 
Upvote 0

Artur2024

Member
Thank you Erel.
Initially I tried "StartActivity" but ....
The solution is simple when someone tells you what to do :)

Add to Widget_4x1
B4X:
Private Sub Label2_Click
    StartActivity (Activity2)
End Sub

Public Sub SetLabel2 (text As String)
    rv.SetText ("Label2", text)
    rv.UpdateWidget
End Sub

Add a new Activity (with me "Activity2")
After clicking the Button (in "Activity2") we can change label2.

in the new Activity:
B4X:
Private Sub Button1_Click
    Dim t As String = EditText1.Text
    CallSub2 (Widget_4x1, "SetLabel2", t)
    Activity.Finish
End Sub
If someone needs, an example is in the attachment.
Click on Label2 (the second one is in Widget_4x1). Works in B4A.

ps. I have several dozen years of programming experience, but I am still learning B4X.
 

Attachments

  • Widget Test.zip
    155.2 KB · Views: 144
Upvote 0
Top