Android的EditText文字动态监听

    科技2022-08-09  97

    EditText et=findViewById(R.id.activity_query_et); et.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { /*Toast.makeText(QueryActivity.this, "开始输入", Toast.LENGTH_SHORT).show();*/ } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { /*Toast.makeText(QueryActivity.this, "文字变化", Toast.LENGTH_SHORT).show();*/ EditText et=findViewById(R.id.activity_query_et); if(et.getText().toString().equals("")){ List<String> list=new ArrayList<String>(); list=getAllItems(R.raw.shl); displayListView(list); } } @Override public void afterTextChanged(Editable s) { /*Toast.makeText(QueryActivity.this, "输入结束", Toast.LENGTH_SHORT).show();*/ } });

    Processed: 0.025, SQL: 8