如何在文字上书写时显示图像

时间:2015-03-05 10:25:59

标签: java android android-edittext

我希望在用户在EditText

上书写时显示图片

触摸EditText时的输出相同:

menuH.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                menuH2.setVisibility(VISIBLE);
                return true;
            }
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                menuH2.setVisibility(View.INVISIBLE);
                Intent intent = new Intent(getApplicationContext(),  Index.class);
                startActivity(intent);
            }

            return true;
        }
    });

所以,我需要执行相同输出的功能,但是当用户在EditText上写字时,感谢先进:)


说明:

看看图片:

enter image description here

当用户在编辑文本上写我想要显示图像时,如果我们假设(abbruch和ok)是图像,那么我想在写作时显示它们,但是当用户停止在{{1}上书写时并切换到另一个编辑文本图像消失

1 个答案:

答案 0 :(得分:1)

尝试TextChangedListener,例如:

menuH.addTextChangedListener(new TextWatcher() {

            @Override
            public void afterTextChanged(Editable s) {
                // TODO Auto-generated method stub

            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // Show your image

            } 

        });
相关问题