Android Question Strange spinner problem

Discussion in 'Android Questions' started by Sanxion, Dec 8, 2015.

  1. Sanxion

    Sanxion Active Member Licensed 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.
     
  2. eurojam

    eurojam Well-Known Member Licensed User

    any code?
     
  3. Sanxion

    Sanxion Active Member Licensed User

    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
     
  4. udg

    udg Expert Licensed User

    Hi, shouldn't spinner be initialized with reference to an event?

    Code:
    myspinner.Initialize("sp1")
    sp1_Itemclick
    sorry for the very short message, but I'm on the road at the moment.
     
  5. Sanxion

    Sanxion Active Member Licensed User

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

    udg Expert Licensed 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.
     
  7. eurojam

    eurojam Well-Known Member Licensed 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
    ستيفان
     
  8. Sanxion

    Sanxion Active Member Licensed User

    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.
     
  9. eurojam

    eurojam Well-Known Member Licensed 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...?
     
  10. Sanxion

    Sanxion Active Member Licensed User

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

    Sanxion Active Member Licensed 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!
     
  12. eurojam

    eurojam Well-Known Member Licensed 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("اَلطَّوِيْلُ")
     
  13. Sanxion

    Sanxion Active Member Licensed User

    Yes you are correct! Well spotted.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice