Answer the question
In order to leave comments, you need to log in
Why does the code work on the second click of the button?
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val url = "https://www.cbr-xml-daily.ru/daily_json.js"
val nameList = ArrayList<String>()
rqbtn.setOnClickListener {
val queue = Volley.newRequestQueue(this)
val stringRequest = StringRequest(com.android.volley.Request.Method.GET, url,
{ response ->
nameList.add(response.substring(0, response.length))
},
{ println("That didn't work!") })
queue.add(stringRequest)
rqview.adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, nameList)
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question