mardi 31 août 2021

How to integerList.add(randomNumber)

I'm not a expert in Android Kotlin and any idea will be appreciate. Why can't I add my randIndex in the integerList ? I'm looking for what I messed for hours now.

    private var integerList: MutableList<Int>? = null

private fun showSpinner() {
    var sv_mvmtChoosed = ""

    /* SCROLL VIEW */
    var linearLayout: LinearLayout? = null
    linearLayout = findViewById(R.id.linear1)
    val layoutInflater = LayoutInflater.from(this)

    var randIndex = 0
    for (i in sv_mvmtName) {
        val rand = Random()
        randIndex = rand.nextInt(40)


            while (integerList!!.contains(randIndex)) {
                randIndex = rand.nextInt(40)
            }
        
        integerList!!.add(randIndex)
        println("**** i = $i  *****  randIndex = $randIndex")
        ...


    }
}



Aucun commentaire:

Enregistrer un commentaire