Addview to Widget

XverhelstX

Well-Known Member
Licensed User
Longtime User
Hello,

I'm testing out the widgets and I have a question.

1) Is it possible to add views to a widget by code as I need this very hard for my app :s

Example:

B4X:
Sub Process_Globals
    Dim rv As RemoteViews
   Dim strWidgetName As String
End Sub

Sub Service_Create

Dim Panel1 As Panel
   Panel1.Initialize("p1")
   
   Dim btn1 As Label
   btn1.Initialize("btn1")
   btn1.BringToFront
   btn1.Text = "This is a label"
   Panel1.addview(btn1,5,5,100,50)

'Panel 1 is the widget in the designer

 rv = ConfigureHomeWidget("Widget", "rv", 0, "Widget")
End Sub

Sub Service_Start (StartingIntent As Intent)
    If rv.HandleWidgetEvents(StartingIntent) Then Return
   

End Sub

I really need this. Is there a possible way to do this?$


Can you make your widget name a customizable string?

2)

Compiling code. Error
Error compiling program.
Error description: A string constant is expected.
Occurred on line: 45
rv = ConfigureHomeWidget("Widget", "rv", 0, strWidgetName)
Word: strwidgetname

Thanks,

XverhelstX
 

XverhelstX

Well-Known Member
Licensed User
Longtime User
Okay, so now I know that the layout file is in: Objects\res\layout\widget_layout.xml.
But is it now possible to modify and add text to widget_layout.xml programmatically?

If yes, what is the link to it?
e.g.
File.dirAssets & "\res\layout\","widget_layout.xml"


XverhelstX
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…