我試圖發送數據到我的數據庫,當我的註冊按鈕被點擊時沒有填寫註冊表單上的任何字段,它顯示「字段空」的消息,但是當我填充它並點擊寄存器按鈕沒有反應。 這是應該發送的數據發送數據到mySQL數據庫
btn_signup.setOnClickListener(this);
Button btn_signup = (Button) view.findViewById(R.id.btn_signup);
btn_signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
registerUser();
}
});
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.tv_login:
break;
}
}
private void registerUser() {
String name = et_name.getText().toString();
String email = et_email.getText().toString();
String password = et_password.getText().toString();
if (!name.isEmpty() && !email.isEmpty() && !password.isEmpty()) {
} else {
Snackbar.make(getView(), "Fields are empty !", Snackbar.LENGTH_LONG).show();
}
}
StringRequest strReq = new StringRequest(Method.POST,
AppConfig.URL_REGISTER, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, "Register Response: " + response.toString());
hideDialog();
我定義我的URL_REGISTER在我AppConfig.java這樣
public class AppConfig {
public static String URL_LOGIN = "http://192.168.43.142/android_login_api/login.php";
public static String URL_REGISTER = "http://192.168.43.142/android_login_api/register.php";
}
哪裏是應該擊中登錄端點的異步任務? –
@Tim It's Volley ...'StringRequest' –