private class TextChangeWatcher implements TextWatcher { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { String username = mUserNameET.getText().toString().trim(); if (TextUtils.isEmpty(username)) { return; } Map<String, String> map = new HashMap<String, String>(); map.put("nickname", username); VolleyRequest.RequestPost(MyApplication.getContext(), Allurl.queryFriends, "getUserData", map, new VolleyInterface(MyApplication.getContext(), VolleyInterface.mlistener, VolleyInterface.merrorlistener) { @Override public void onMySuccess(String response) { MyLog.i("test26", "respnse = " + response); if (!response.equals("error")) { MyLog.i("test26", "response = " + response); } else { Toast.makeText(LoginActivity.this, "服务器返回错误!", Toast.LENGTH_SHORT).show(); } } @Override public void onMyError(VolleyError error) { Toast.makeText(LoginActivity.this, "网络异常!", Toast.LENGTH_SHORT).show(); } });}
用法:
Etidtext.addTextChangedListener(new TextChangeWatcher());
EditText动态输入监听
最新推荐文章于 2023-06-24 09:00:00 发布