How to change string from arraylist in kotlin

Viewed 40

This is my coding for exoplayer 2. I tried to make a list of episode and whenever the episode click, the string value gonna change by accessing the array list. Is there any alternate way to do this. Thank you!

       val playerView = findViewById<StyledPlayerView>(R.id.player)
    val progressBar = findViewById<ProgressBar>(R.id.progress_bar)
    val bt_fullscreen = findViewById<ImageView>(R.id.bt_fullscreen)
    val bt_lockscreen = findViewById<ImageView>(R.id.exo_lock)
    val total_episode = 2
    val episode_number = arrayListOf<String>()
    val episode_link =
        arrayListOf<String>(
            "https://download941.mediafire.com/9x5p0xunyhig/txs1m4i2pjv01ay/hasil.mp4",
            "https://www269.ff-01.com/token=yv8LUf_fCoY-MMB_ZIUbfA/1661176164/182.1.0.0/7/5/6b/159f0f122232ece4ff931ed7ba0696b5-480p.mp4"
        )

    for (item in 0..total_episode) {
        if (item <= total_episode) {
            val itemtotal = item
            episode_number.add("Episode $itemtotal")
        }
    }

    var address = String()
    val arrayAdapter = ArrayAdapter(this, R.layout.item_form_dropdown, episode_number)
    val episodebox_input = findViewById<AutoCompleteTextView>(R.id.episodebox_input)
    episodebox_input.setAdapter(arrayAdapter)
    episodebox_input.onItemClickListener = object : AdapterView.OnItemClickListener {
        override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, Id: Long) {
            val SelectedItem = parent?.getItemAtPosition(position).toString()
            for (item in 0..total_episode) {
                val itemnum = item+1
                if (SelectedItem.contains(itemnum.toString())) {
                    val link = episode_link[item]
                    address.replace(adress,link)    
                }
            }
        }
0 Answers
Related