你能告诉我如何使用textwatcher吗

你能告诉我如何使用textwatcher吗

本文介绍了你能告诉我如何使用textwatcher吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void addKeyListener() {

    // get edittext component
    edittext = (EditText) findViewById(R.id.editText);
    edittext1 = (EditText) findViewById(R.id.editText1);



    // add a keylistener to keep track user input
    edittext.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int keyCode, KeyEvent event) {

        // if keydown and "enter" is pressed
            if(keyCode == EditorInfo.IME_ACTION_GO)
        {
            edittext1.requestFocus();
            return true;
        }


        return false;
     } });

     edittext1.setOnEditorActionListener(new TextView.OnEditorActionListener() {
             @Override
             public boolean onEditorAction(TextView a, int b, KeyEvent c) {

        // if keydown and "enter" is pressed
             if(b == EditorInfo.IME_ACTION_GO) {

            //hide the keyboard
             InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
             imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
             imm.hideSoftInputFromWindow(edittext1.getWindowToken(), 0);
        // display a floating message
            Toast.makeText(MyAndroidAppActivity.this, edittext.getText().toString() + " " + edittext1.getText().toString(), Toast.LENGTH_SHORT).show();
            return true;
        }

        return false;
      } });

 }



你能告诉我如何使用文本观察器,应该在android 4.4中工作。请帮帮我



请重写完整代码并告诉我


Can you tell me how to use text watcher and should work in android 4.4. Please help me

Please rewrite the complete code and tell me

推荐答案


这篇关于你能告诉我如何使用textwatcher吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 08:59