Android Question Spinner ItemClick Event Promlem

KL7000F

Member
Licensed User
Longtime User
hello,
I have a problem with the ItemClick event of a spinner.
I've added a Custom Dialog with two spinners.

B4X:
Sub KreiskuerzelAuswaehlen
    Dim pnl As Panel
    Dim Lbl1, Lbl2 As Label
    Dim cd As CustomDialog2
    pnl.Initialize("pnl")
    Lbl1.Initialize("Lbl1")
    Lbl2.Initialize("Lbl2")

    'Spinner initialize in Activity_Create

    pnl.AddView(Lbl1, 30dip, 30dip, 75%x, 30dip)
    pnl.AddView(spin1, 30dip, 70dip, 75%x, 30dip)
    pnl.AddView(Lbl2, 30dip, 110dip, 75%x, 30dip)
    pnl.AddView(spin2, 30dip, 150dip, 75%x, 30dip)

    Lbl1.Text = "Bundesland wählen:"
    Lbl1.TextSize = 18
    Lbl2.Text = "Stadt / Landkreis wählen:"
    Lbl2.TextSize = 18

    Dim BLArray(12) As String
    BLArray(0)="Baden-Württemberg"
    BLArray(1)="Bayern"
    BLArray(2)="Brandenburg / Berlin"
    BLArray(3)="Hessen"
    BLArray(4)="Mecklenburg-Vorpommern"
    BLArray(5)="Niedersachsen / Bremen"
    BLArray(6)="Nordrhein-Westfalen"
    BLArray(7)="Rheinland-Pfalz / Saarland"
    BLArray(8)="Sachsen"
    BLArray(9)="Sachsen-Anhalt"
    BLArray(10)="Schleswig-Holstein / Hamburg"
    BLArray(11)="Thüringen"

    spin1.Clear
    spin1.TextColor = Colors.Gray
    spin1.AddAll(BLArray)
    spin1.SelectedIndex = 0

    spin2.Clear
    spin2.TextColor = Colors.Gray
    LandkreiseAuslesen("bawue.csv") 'Vorausgewähltes Bundesland wählen... Nummer 0 vom BLArray

    cd.AddView(pnl, 90%x, 200dip)
    cd.Show("Stadt / Landkreis wählen", "Speichern", "Abbruch", "", Null) 'Cancel = -3 ; Positiv = -1

    If cd.Response = -1 Then
        Log("Positiv gedrückt")
        'Hier Programmcode zum Speichern vom Kürzel...
    Else If cd.Response = -3 Then
        Log("Cancel gedrückt")
        'Wird geschlossen, nichts weiter vornehmen...
    End If

    pnl.RemoveAllViews
End Sub

After selection in Spinner1 a ItemClick event to run at Spinner2 to fill with data here.
This event is executed but only if the Custom dialog is closed after press a button.

B4X:
Sub spin1_ItemClick(Position As Int, Value As Object)
    Log(Position & " - " & Value)
 
    spin2.Clear
    Select Position 'spin1.SelectedIndex
        Case 0
            LandkreiseAuslesen("bawue.csv")
        Case 1
            LandkreiseAuslesen("bayern.csv")
        Case 2
            LandkreiseAuslesen("brabuberlin.csv")
        Case 3
            LandkreiseAuslesen("hessen.csv")
        Case 4
            LandkreiseAuslesen("meckpom.csv")
        Case 5
            LandkreiseAuslesen("niedsachsenbremen.csv")
        Case 6
            LandkreiseAuslesen("nrw.csv")
        Case 7
            LandkreiseAuslesen("rlpsaarland.csv")
        Case 8
            LandkreiseAuslesen("sachsen.csv")
        Case 9
            LandkreiseAuslesen("sachsenanhalt.csv")
        Case 10
            LandkreiseAuslesen("schleswighamburg.csv")
        Case 11
            LandkreiseAuslesen("thueringen.csv")
        Case Else
            spin2.Clear
            spin2.Add("Bundesland wählen...")
    End Select
End Sub


EDIT: I have just tested it again. ItemClick works, but not when spinner is in a Custom Dialog. Is there a solution for this?

greets
Andy
 
Last edited:
Top