Scrollview & added spinner & edittext

Rigsby

Member
Licensed User
Longtime User
Hi,

I am having a problem with various objects added to a scrollview that is a tab in a TabHost. I am unable to get spinner & textbox values of these items. I can create them OK, I can populate the spinners OK. But afterwards, in the rest of the program, you are unable to get the spinSendEOB.SelectedIndex, it always returns value zero no matter which item has been selected, and txtSendBefore.text is always blank, no matter what has been typed in.

Is it possible to get the values without having to resort to using tags ? Thanks.

Code fragments...........

Sub Globals
Dim scvMain As ScrollView
Dim TabHost1 As TabHost
Dim spinSendEOB,spinCharDelay,spinReceiveEOB As Spinner
dim txtSendBefore As EditText
end sub

Sub Activity_Create(FirstTime As Boolean)

.
.
.
.

scvMain.Initialize(100%y)
TabHost1.AddTab ( "Send", "tab1")
TabHost1.AddTab2("Settings",scvMain)
FillScrollView

end sub

Sub FillScrollView

i = 0

' add a label
Dim lbl As Label
lbl.Initialize("lbl1")
lbl.Color = Colors.black
lbl.Text = "Some Text"
scvMain.Panel.AddView(lbl,0, i*lblHeight1, lblWidth, lblHeight)

' add a spinner
spinSendEOB.Initialize("spinSendEOB")
spinSendEOB.Add("CR/LF")
spinSendEOB.Add("LF/CR/CR")
spinSendEOB.Add("LF")
spinSendEOB.Add("CR")
scvMain.Panel.AddView(spinSendEOB,lblWidth,i*lblHeight1,objwidth,lblHeight+2)

' add a text box
txtSendBefore.Initialize("txtSendBefore")
scvMain.Panel.AddView(txtSendBefore,2*lblWidth,i*lblHeight1,objwidth,lblHeight+2)



end sub
 

Rigsby

Member
Licensed User
Longtime User
Code fragments...........

Sub Globals
Dim scvMain As ScrollView
Dim TabHost1 As TabHost
Dim spinSendEOB,spinCharDelay,spinReceiveEOB As Spinner
dim txtSendBefore As EditText
end sub

Sub Activity_Create(FirstTime As Boolean)

.
.
.
.

scvMain.Initialize(100%y)
TabHost1.AddTab ( "Send", "tab1")
TabHost1.AddTab2("Settings",scvMain)
FillScrollView

end sub

Sub FillScrollView

i = 0

' add a label
Dim lbl As Label
lbl.Initialize("lbl1")
lbl.Color = Colors.black
lbl.Text = "Some Text"
scvMain.Panel.AddView(lbl,0, i*lblHeight1, lblWidth, lblHeight)

' add a spinner
spinSendEOB.Initialize("spinSendEOB")
spinSendEOB.Add("CR/LF")
spinSendEOB.Add("LF/CR/CR")
spinSendEOB.Add("LF")
spinSendEOB.Add("CR")
scvMain.Panel.AddView(spinSendEOB,lblWidth,i*lblHe ight1,objwidth,lblHeight+2)

' add a text box
txtSendBefore.Initialize("txtSendBefore")
scvMain.Panel.AddView(txtSendBefore,2*lblWidth,i*l blHeight1,objwidth,lblHeight+2)

end sub


>>>>>>>>>>>>>>>>>>>>>>>

There is nothing in the label event. If you click the spinner, it reflects the position, and the text accurately from it's itemclick event. If you try to access the same properties from a button also added to the scrollview (I have tried this not added to the scrollview and it is the same effect) you never get the correct position, it always reflects the first value in the spinner. Thanks for any info...

>>>>>>>>>>>>>>>>>>>>>>>

Sub lbl1_click
Msgbox("Clicking This Is Pointless Really","It's Just A Click Event")
End Sub

Sub spinSendEOB_ItemClick (Position As Int, Value As Object)
Msgbox("You Clicked " & spinSendEOB.GetItem(Position), "Position " & Position)
End Sub


Sub btnSaveIni_click

Msgbox (spinSendEOB.GetItem(spinSendEOB.SelectedIndex),spinSendEOB.SelectedItem)
saveIni

End Sub
 
Upvote 0

Rigsby

Member
Licensed User
Longtime User
Thank you Klaus, a good idea.

I have attached the project.

I have just added a single spinner to the scrollview, there are about a further 8 I need added as well as text boxes, but I removed them to make it simpler to debug.

If you click the 2nd tab marked Settings, and click the Save Settings button, it always reflects the first value in the spinner list "CR/LF". But if you click the spinner itself, its click event reflects the correct value.

It does this for all added spinners and textboxes.

Thanks for any help.
 

Attachments

  • test4droid.zip
    18.4 KB · Views: 327
Upvote 0

klaus

Expert
Licensed User
Longtime User
Comment out these two lines 152 and 154 at the end of Activity_Create !!!!!!
B4X:
'    scvMain.Initialize(150dip)
    
'    FillScrollView
It took me tabout two hours to find this out !
Tested a lot of things.
I hadn't looked at the end of Activity_Create and didn't see that you called FillScrollView TWO TIMES !

Best regards.
 
Upvote 0

Rigsby

Member
Licensed User
Longtime User
Thank you so much Klaus, that fixes it. (I spent much more than 2 hours going around in circles)

Thanks again!!
 
Upvote 0
Top