I tried to make the drop down have a certain amount of choice whenever the total input defined. And by that, each choices could access certain link in array list by index and apply it on the variable of "link_video" that going to pass for the exoplayer. Basically, my problems is the "episode" show 3 choices and it seems the variable doesn't change. Anyway, Idk if its bad idea or not. but if it was, please show me the right way. Thank you
var link_video ="video"
private fun dropdown() {
val total_episode = 2
val episode_number = arrayListOf<String>("")
val number = arrayListOf<Int>()
val episode_link =
arrayListOf<String>(
"http://download2263.mediafire.com/okgtas0jidsg/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+1
episode_number.add("Episode $itemtotal")
number.add(item)
} else break
}
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.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onNothingSelected(parent: AdapterView<*>?) {
}
override fun onItemSelected(
parent: AdapterView<*>?,
view: View?,
position: Int,
id: Long
) {
val SelectedItem = parent?.getItemAtPosition(position).toString()
for (item in number) {
if (SelectedItem == number.toString()) {
val link = episode_link[item+1]
link_video.replace(link_video, link)
return
} else continue
}
}
}