public class MainActivity extends AppCompatActivity { String code = "QQ"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final EditText editText = (EditText) findViewById(R.id.editText); final TextView textView = (TextView) findViewById(R.id.textView); editText.addTextChangedListener(new TextWatcher() { public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { if (TextUtils.isEmpty(charSequence)) { } else { } } public void afterTextChanged(Editable editable) { if (!editText.getText().toString().equals("")) { long b = Long.parseLong(editText.getText().toString()); textView.setText(String.valueOf((9999 - b) * (9999 - b))); return; } textView.setText("0"); } }); } }
android 检测EditText更改
最新推荐文章于 2024-08-09 07:14:09 发布