我有一个具有登录按钮的登录活动。当我单击该按钮时,执行此代码:
Response.Listener<String> responseListener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
if (success){
toastMessage.makeMessage("Logging in...");
int user_ID = jsonResponse.getInt("userId");
String username = jsonResponse.getString("username");
saveUserData(user_ID, username);
Intent intent = new Intent(Login.this, MainMenu.class);
startActivity(intent);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(Login.this);
builder.setMessage("Username or password incorrect")
.setNegativeButton("Retry", null)
.create()
.show();
}
} catch (JSONException e) {
AlertDialog.Builder builder1 = new AlertDialog.Builder(Login.this);
builder1.setMessage("Error").create().show();
e.printStackTrace();
}
}
};
LoginRequest loginRequest = new LoginRequest(username, password, responseListener);
RequestQueue queue = Volley.newRequestQueue(Login.this);
queue.add(loginRequest);
但是当我点击登录按钮时,在点击登录按钮约5或6次之前没有任何凌空响应。我第一次点击它,我等待15-20秒,没有任何反应。然后我再次点击它,等待15-20秒,没有任何反应。但当我开始垃圾邮件时,单击按钮就可以了。我希望它在我第一次点击它时回复并且不想要垃圾邮件点击登录按钮。这里出了什么问题?