Some Doubts

diego

Member
Licensed User
Longtime User
Just started B4A programming and I'm still lost... :sign0085:


- SET TIME: what is the instruction to set the device time?

- TABLES ? is there any view similar to B4PPC Table to show/edit 'n' values?

- SPINNER: sample code please? I cannot make it work whit this...

B4X:
  Sub Globals
     Dim myList(99) as string
     Dim mySel as Spinner
  End Sub

  myList(1) = "item1"
  myList(2) = "item2"
  myList(3) = "item3"
  mySel.Initialize("mySel")   ' (I don't understand EventName parameter here)
  mySel.AddAll(myList)

When I run it, there is no list in the combo.

thanks in advance
 

Cableguy

Expert
Licensed User
Longtime User
- SPINNER: sample code please? I cannot make it work whit this...

B4X:
  Sub Globals
     Dim myList(99) as string
     Dim mySel as Spinner
  End Sub

  myList(1) = "item1"
  myList(2) = "item2"
  myList(3) = "item3"
  mySel.Initialize("mySel")   ' (I don't understand EventName parameter here)
  mySel.AddAll(myList)

When I run it, there is no list in the combo.

thanks in advance

You need to add it to the view...
Activity.AddView(MySel,80%x,0,100%x,100%y), will palece the spinner at right side, full view lenght
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
- Currently you cannot set the system time.
- There is no Table control in Android like the one Windows Mobile.

Here is an example:
B4X:
Sub Globals
    Dim Spinner1 As Spinner
    Dim myList(99) As String

End Sub
 

Sub Activity_Create(FirstTime As Boolean)
    myList(1) = "item1"
    myList(2) = "item2"
    myList(3) = "item3"
    Spinner1.Initialize("TheSubThatWillHandleTheEvent")
    'Spinner1.AddAll(Array As String("item1", "item2", "item3")) 'Another option
    Spinner1.AddAll(myList)
    Activity.AddView(Spinner1, 20dip, 20dip, 200dip, 60dip)
End Sub
Sub TheSubThatWillHandleTheEvent_ItemClick (Position As Int, Value As Object)
    Activity.Title = Value    
End Sub
 
Upvote 0

diego

Member
Licensed User
Longtime User
Adding the spinner now I can see the options in the 'combo', but still I have problems:

-the event doesn't raise, ¿should I add an "Spinner1_ItemClick" sub?

-the spinner added is 'floating' in the screen because I want to use tabs but I don't know how to add the spinner to the correct layout.

-previously I inserted the spinner with the designer, but clicking on it I just see an empty box and there's no way to close it:

spinner.jpg




:BangHead::BangHead::BangHead:
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
In my example I added a sub that handles the event:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    myList(1) = "item1"
    myList(2) = "item2"
    myList(3) = "item3"
    Spinner1.Initialize("TheSubThatWillHandleTheEvent") '<-Here we set the sub that will handle the events
    'Spinner1.AddAll(Array As String("item1", "item2", "item3")) 'Another option
    Spinner1.AddAll(myList)
    Activity.AddView(Spinner1, 20dip, 20dip, 200dip, 60dip)
End Sub
Sub TheSubThatWillHandleTheEvent_ItemClick (Position As Int, Value As Object)
    Activity.Title = Value

Did you go over the TabHost tutorial? http://www.b4x.com/forum/basic4android-getting-started-tutorials/6721-tabhost-tutorial.html
 
Upvote 0

diego

Member
Licensed User
Longtime User
Sorry, I put
Spinner1.Initialize("TheSubThatWillHandleTheEvent_ItemClick") instead of

Spinner1.Initialize("TheSubThatWillHandleTheEvent")

now the event raises Ok.

Still I don't know how to put the spinner in the second tab, in Activity_Create is previously loaded: TabHost1.AddTab("List", "list.bal") so I guess there is a way to modify the file list.bal programmaticaly. If I put the spinner directly with the Designer it doesn't work.
 
Upvote 0

diego

Member
Licensed User
Longtime User
Finally it works! :)

I took a while to relax, started a new project (the tabs sample) and added a spinner in the designer.

Just using myList.addAll(list) it works, it is not necessary to Initialize it.

thanks a lot and sorry for my obtuseness.

my new challenge is to find a way to create a 'table' and show and save different data according to selected item in the spinner. SQL would be the way?
 
Upvote 0
Top