Android Question Strange spinner problem

Sanxion

Active Member
Licensed User
Longtime User
Guys

I have two spinners. Both have been declared in Globals along with their Maps and two strings to store the value of each spinner.

Both Maps have been initialized in a Sub and words have been added to each spinner/map via the .Add and .Put methods.

However, when I attempt to assign the value of each spinner map using the .Get(Value) method to its string, the following appears:

First spinner map: the value of the spinner appears when I hover the cursor over the .Get(Value) method and it appears in the string assigned to it.
Second spinner map: the value of the spinner appears when I hover the cursor over the .Get(Value) method but it appears as 'null' in the string assigned to it - as thought the value is becoming 'lost' when assigning it to its string.

It is quite bizarre. Any ideas?

Thank-you.
 

Sanxion

Active Member
Licensed User
Longtime User
any code?

Ok...

Sub Global

Private spnL3A16AW1,spnL3A16AW2 As Spinner

Private spnMapL3A16AW1, spnMapL3A16AW2 As Map

Private arabicWord1L3A16, arabicWord2L3A16 As String

End Sub

Sub Lesson3Activity16

spnMapL3A16AW1.Initialize
spnMapL3A16AW2.Initialize
spnL3A16AW1.Add("وَلَدٌ")
spnMapL3A16AW1.Put("وَلَدٌ", "a boy")
spnL3A16AW1.Add("اَلْوَلَدُ")
spnMapL3A16AW1.Put("اَلْوَلَدُ", "the boy")
spnL3A16AW1.Add("طَوِيْلٌ")
spnMapL3A16AW1.Put("طَوِيْلٌ", "tall")
spnL3A16AW1.Add("اَلطَّوِيْلٌ")
spnMapL3A16AW1.Put("اَلطَّوِيْلُ", "the tall")

spnL3A16AW2.Add("وَلَدٌ")
spnMapL3A16AW2.Put("وَلَدٌ", "a boy")
spnL3A16AW2.Add("اَلْوَلَدُ")
spnMapL3A16AW2.Put("اَلْوَلَدُ", "the boy")
spnL3A16AW2.Add("طَوِيْلٌ")
spnMapL3A16AW2.Put("طَوِيْلٌ", "tall")
spnL3A16AW2.Add("اَلطَّوِيْلٌ")
spnMapL3A16AW2.Put("اَلطَّوِيْلُ", "the tall")

End Sub

Sub spnL3A16AW1_ItemClick (Position As Int, Value As Object)

arabicWord1L3A16 = spnMapL3A16AW1.Get(Value)

If arabicWord1L3A16 = "the boy" And arabicWord2L3A16 = "the tall" Then
ivResult.Visible = True
End If

End Sub

Sub spnL3A16AW2_ItemClick (Position As Int, Value As Object)

arabicWord2L3A16 = spnMapL3A16AW2.Get(Value)

If arabicWord1L3A16 = "the boy" And arabicWord2L3A16 = "the tall" Then
ivResult.Visible = True
End If

End Sub
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi, shouldn't spinner be initialized with reference to an event?

B4X:
myspinner.Initialize("sp1")
sp1_Itemclick

sorry for the very short message, but I'm on the road at the moment.
 
Upvote 0

Sanxion

Active Member
Licensed User
Longtime User
Hi, shouldn't spinner be initialized with reference to an event?

B4X:
myspinner.Initialize("sp1")
sp1_Itemclick

sorry for the very short message, but I'm on the road at the moment.

I am not sure what you mean - are you saying they cannot be initialized except in an event related to them?
 
Upvote 0

udg

Expert
Licensed User
Longtime User
No. I mean I can't see in your code the spinners initialization while recalling that the event name to use before the itemclick should be the same used for initialization.
If you already have spnL3A16AW1.initialize("spnL3A16AW1") somewhere, just disregard my message. Same for AW2.
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
the problem is that in your spnL3A16AW1_ItemClick sub the arabicWord2L3A16 is not set. it will be set when the user clicks the spinner2. The result is, thatyour condition will not be true....

best regards
ستيفان
 
Upvote 0

Sanxion

Active Member
Licensed User
Longtime User
the problem is that in your spnL3A16AW1_ItemClick sub the arabicWord2L3A16 is not set. it will be set when the user clicks the spinner2. The result is, thatyour condition will not be true....

best regards
ستيفان

Yes I understand that but it is not a problem as the user will have to click on each spinner individually, so they should be set.

My issue is related to arabicWord2L3A16 not being set despite clicking on spnL3A16AW2.
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
that is strange, on my device your code works perfectly, if I click on "al walid" on spinner 1 and on "al thawiil" on sppinner2 all goes correct...?
 
Upvote 0

Sanxion

Active Member
Licensed User
Longtime User
that is strange, on my device your code works perfectly, if I click on "al walid" on spinner 1 and on "al thawiil" on sppinner2 all goes correct...?

When I try it, the last entry isn't recognised when selected in either of the spinners. Both show a null string.
 
Upvote 0

Sanxion

Active Member
Licensed User
Longtime User
I have resolved it...there was a spurious character at the end of the word that was ordinarily hidden - it appears it was affecting the spinner.

Thanks for all those who replied!
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
yes, you are right, but it is a problem of the map, not the spinner,

you wrote "al thawiil" different in the spinner and the map...look at the vocalisation of the last letter
spnL3A16AW2.Add("اَلطَّوِيْلٌ")
spnMapL3A16AW2.Put("اَلطَّوِيْلُ")
 
Upvote 0

Sanxion

Active Member
Licensed User
Longtime User
yes, you are right, but it is a problem of the map, not the spinner,

you wrote "al thawiil" different in the spinner and the map...look at the vocalisation of the last letter
spnL3A16AW2.Add("اَلطَّوِيْلٌ")
spnMapL3A16AW2.Put("اَلطَّوِيْلُ")

Yes you are correct! Well spotted.
 
Upvote 0
Top