Hello everybody,
I try to use custom controlls on the ScrollView.
1) I load the layouts with b4xplusminus controls,
2) I make the array of the controls and with panels with the code:
3) then I try to fill the scrollview:
But it does not work properly. Please help me!
Here is the whole code:
I attached the zip-file as well!
Thanks!
Mario
I try to use custom controlls on the ScrollView.
1) I load the layouts with b4xplusminus controls,
2) I make the array of the controls and with panels with the code:
B4X:
Mood = Array As B4XPlusMinus (B4XPlusMinus1, B4XPlusMinus2, B4XPlusMinus3,B4XPlusMinus4)
pan = Array As Panel (Pan1, Pan2, Pan3,Pan4)
B4X:
ScrollView1.Panel.AddView(pan(i), 2dip, i* 120dip +35dip , 300dip, 30dip)
Mood(i).SetNumericRange(0, 10, 1)
Mood(i).SelectedValue=0
Mood(i).Tag = i +1
But it does not work properly. Please help me!
Here is the whole code:
B4X:
#Region Project Attributes
#ApplicationLabel: test
#VersionCode: 1
#VersionName: 1
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private DobaDana() As String
DobaDana = Array As String("Last night","Morning", "Afternoon", "Evening" )
Private lbl(4) As Label
Private i As Int
'Private StimmPlMin(4) As B4XPlusMinus
Private ScrollView1 As ScrollView
Private Mood(4) As B4XPlusMinus
Private pan(4) As Panel
Private B4XPlusMinus1 As B4XPlusMinus
Private B4XPlusMinus2 As B4XPlusMinus
Private B4XPlusMinus3 As B4XPlusMinus
Private B4XPlusMinus4 As B4XPlusMinus
Private Pan1 As Panel
Private Pan2 As Panel
Private Pan3 As Panel
Private Pan4 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("plusminus1")
Activity.LoadLayout("plusminus2")
Activity.LoadLayout("plusminus3")
Activity.LoadLayout("plusminus4")
'is it reasonably to load layout and remove all views, to be ably to use custom controlls??
Activity.RemoveAllViews
Activity.LoadLayout("Stimmungstagebuch")
Activity.Title="Mood diary"
Mood = Array As B4XPlusMinus (B4XPlusMinus1, B4XPlusMinus2, B4XPlusMinus3,B4XPlusMinus4)
pan = Array As Panel (Pan1, Pan2, Pan3,Pan4)
FillScrollView
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub FillScrollView
Try
For i=0 To 3
'HERE IS EVERYTHING OK.
lbl(i).Initialize ("lbl")
lbl(i).TextColor = Colors.Black
lbl(i).Gravity=Gravity.CENTER_HORIZONTAL
lbl(i).Text =DobaDana(i)
ScrollView1.Panel.AddView(lbl(i), 2, i* 120dip , 100%x, 30dip)
'HERE THERE ARE PROBLEMS:
ScrollView1.Panel.AddView(pan(i), 2dip, i* 120dip +35dip , 300dip, 30dip)
Mood(i).SetNumericRange(0, 10, 1)
Mood(i).SelectedValue=0
Mood(i).Tag = i +1
Next
Catch LastException
MsgboxAsync ( LastException.Message,"Fehler" )
End Try
End Sub
Thanks!
Mario