Dim anInputDialog As InputDialog
anInputDialog.Input=Value
anInputDialog.Show("New Value:","Edit Pos" & Position & " - " & Value,"OK","Cancel","",Null)
If anInputDialog.Response=DialogResponse.POSITIVE Then
Dim newValue As String=anInputDialog.Input
aList.Initialize
aList.InsertAt(Position,newValue)
aList.RemoveAt(Position)
spnNameTeams.Clear
spnNameTeams.AddAll(aList)
Msgbox(aList,"alist")
End If
So, you are Adding a value at position 0 for ex.aList.InsertAt(Position,newValue)
aList.RemoveAt(Position)
Well now it runs all the way through but the spinner doesn't reload with values. The spinner is blank.
End If[/CODE]
Dim anInputDialog AsInputDialog
anInputDialog.Input=Value
anInputDialog.Show("New Value:","Edit Pos" & Position & " - " & Value,"OK","Cancel","",Null)If anInputDialog.Response=DialogResponse.POSITIVE ThenDim newValue AsString=anInputDialog.Input
' aList.Initialize @@@@@@@ Initialize and populate the list elsewhere ... another sub
aList.InsertAt(Position,newValue)
aList.RemoveAt(Position)
spnNameTeams.Clear
spnNameTeams.AddAll(aList)Msgbox(aList,"alist")EndIf
You are doing the same mistake.aList.InsertAt(Position,newValue)
aList.RemoveAt(Position)
No. You are absolutely right!Edit ... The list should be initialized and populated elsewhere ... or am i missing something ?
You are doing the same mistake.
Adding a item at pos 0 (TEST)
and then removing item 0 (TEST)
will result in the same list as before
Sub aSpinner_ItemClick (Position As Int, Value As Object)Dim anInputDialog AsInputDialog
anInputDialog.Input=Value
anInputDialog.Show("New Value:","Edit Pos" & Position & " - " & Value,"OK","Cancel","",Null)If anInputDialog.Response=DialogResponse.POSITIVE ThenDim newValue AsString=anInputDialog.Input
aList.InsertAt(Position,newValue)
aList.RemoveAt(Position+1)
aSpinner.Clear
aSpinner.AddAll(aList)EndIf
End Sub]
In Activity Create / Resume or Starter service if you have one ..Any suggestions where I should initialize it? I tried the button click that make the spinner visible. But still get a need to initialize error.
Then shouldn't in the button_click process work? That is what I tried and I still get the java.lang.RuntimeException: Object should first be initialized (List).
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main") 'Contains only button
aSpinner.Initialize("aSpinner")
Activity.AddView(aSpinner,0,0,50%x,15%y)
aSpinner.AddAll(Array As String("item 1","item 2","item 3"))
aSpinner.Visible = False
End Sub
Sub aSpinner_ItemClick (Position As Int, Value As Object)
Dim anInputDialog As InputDialog
anInputDialog.Input=Value
anInputDialog.Show("New Value:","Edit Pos" & Position & " - " & Value,"OK","Cancel","",Null)
If anInputDialog.Response=DialogResponse.POSITIVE Then
Dim newValue As String=anInputDialog.Input
aList.InsertAt(Position,newValue)
aList.RemoveAt(Position+1)
aSpinner.Clear
aSpinner.AddAll(aList)
Msgbox(aList,"alist")
End If
End Sub
Sub Button1_Click
aList.Initialize
For i = 0 To aSpinner.Size -1
aList.Add(aSpinner.GetItem(i))
Next
aSpinner.Visible = True
End Sub
Maybe you should start learning the language after you got helpful answersMaybe you can tell me how I should do it.
Maybe you can tell me how I should do it. What happens is the user clicks on the spinner and an input box opens. The user enters a value. I then want that value added to the spinner.
Sub Globals
Private aSpinner As Spinner
Private edtTeams As EditText
Private Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
aSpinner.Initialize("aSpinner")
Activity.AddView(aSpinner,50dip,50dip,50%x,15%y)
edtTeams.Initialize("edtTeams")
edtTeams.TextSize = 24
edtTeams.Hint = "Add New Team"
edtTeams.SingleLine = True
edtTeams.ForceDoneButton = True
edtTeams.Visible = False
Activity.AddView(edtTeams, 50dip,40%y , 20%x, 60dip)
Button1.Initialize("Button1")
Button1.Text = "Add New Team"
Activity.AddView(Button1, 50dip, 60%y, 20%x, 60dip)
End Sub
Sub Button1_Click
edtTeams.Visible = True
End Sub
Sub edtTeams_EnterPressed
aSpinner.Add(edtTeams.Text)
edtTeams.Text = ""
edtTeams.Visible = False
End Sub