Last active
February 26, 2019 08:15
-
-
Save WindSekirun/4f26929857983e8ff5f61731973639a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val btn = findViewById<Button>(R.id.button1) | |
btn.setOnClickListener(object : View.OnClickListener { | |
override fun onClick(v: View?) { | |
requestSend() | |
} | |
}) | |
} | |
fun requestSend() { | |
val jsonobj = JSONObject() | |
jsonobj.put("nim", nim_editText.text) | |
jsonobj.put("nama", nama_editText.text) | |
jsonobj.put("address", address_editText.text) | |
val queue = Volley.newRequestQueue(this) | |
val url = "http://192.168.100.7/simplecrud/create.php" | |
val req = JsonObjectRequest(Request.Method.POST,url,jsonobj, | |
Listener { | |
Toast.makeText(this@MainActivity, "Success", Toast.LENGTH_SHORT).show() | |
}, | |
ErrorListener { | |
Toast.makeText(this@MainActivity, "Error Occured", Toast.LENGTH_SHORT).show() | |
}) | |
queue.add(req) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment