Italian Ho creato una Activity che si apre alla pressione di un tasto ...

kelvo01

Member
Licensed User
Ho creato una Activity che si apre alla pressione di un tasto ...
Ho usato la CustomListView ... ma l'activity altre a non far vedere nulla quitta l'app
Ho allegato il codice, cosa manca o e' errato?



#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.
Dim clv1 As CustomListView
Dim Panel1 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("Layout1")




clv1.Initialize(Me, "clv1")
Panel1.AddView(clv1.AsView, 0, 0, Panel1.Width, Panel1.Height)

clv1.Add(CreateInput("Utente Facebook", clv1.AsView.Width, 50dip), 50dip, "Item #" & 1)

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub clv1_ItemClick (Index As Int, Value As Object)
Activity.Title = Value
End Sub

Sub CreateInput(Text As String, Width As Int, Height As Int) As Panel
Dim p As Panel
p.Initialize("")
p.Color = Colors.Black

Dim lbl As Label
lbl.Initialize("")
lbl.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.LEFT)
lbl.Text = Text
lbl.TextSize = 16
lbl.TextColor = Colors.White

Dim et As EditText
et.Initialize("")

p.AddView(lbl, 5dip, 2dip, 150dip, Height - 4dip) 'view #0
p.AddView(et, 200dip, 2dip, 50dip, Height - 4dip) 'view #1
Return p
End Sub
 

imgsimonebiliato

Well-Known Member
Licensed User
Ciao,
la prossima volta usa il formato CODE per inserire del codice, è più leggibile ;)
da una prima occhiata vedo che non hai inizializzato il Panel1 prima di aggiungere la view:

B4X:
Panel1.Initialize("Panel1")
e in più, se vuoi aggiungere la CustomListView al pannello, devi prima aggiungere il pannello all'Activity. Il tuo codice, per cui, diventerà:

B4X:
Panel1.Initialize("panel1")
clv1.Initialize(Me, "clv1")
Activity.AddView(Panel1, 0, 0, 100%x, 100%y)
Panel1.AddView(clv1.AsView, 0, 50%y, 100%x, 50%y)
 
Top