JSONObject()的错误 – Kotlin

我正在尝试使用Volley Library进行登录视图。 看来“jsonobj”总是空的。

val jsonobj = JSONObject() loginBtn.setOnClickListener { jsonobj.put("mail", mailTxt.text) jsonobj.put("pass", passTxt.text) val que = Volley.newRequestQueue(this@MainActivity) val req = JsonObjectRequest(Request.Method.POST, url, jsonobj, Response.Listener{ response -> toast(response["error"].toString()) }, Response.ErrorListener { toast("Error") }) que.add(req) } } }