how to make hint disappear when edittext is touched?

后端 未结 12 1167
青春惊慌失措
青春惊慌失措 2020-12-14 00:39

In my application in android are many EditText fields. And I ran into a problem with hint. It is not disappearing when EditText is focused, but it disappears when I start to

12条回答
  •  执念已碎
    2020-12-14 00:59

    Every Given Solution may work or not I don't know but the Following steps would definitely help.

    First Create a dummy focus to restrain the EditText from gaining focus by

        
    

    Then Normally set hint in your EditText as example:

        
    

    Finally add the following code in your activity or fragment where you intend

        editText.setOnTouchListener(new View.OnTouchListener() {
    
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                editText.setHint("");
                return false;
            }
    
        });
    

提交回复
热议问题