Android: Evaluate EditText after the user finishes editing

前端 未结 4 1581
[愿得一人]
[愿得一人] 2020-12-18 08:17

What I want I have an EditText, where the user can enter a value, such as 10.40. Once the user is done editing I am formatting his input to a currency, for

4条回答
  •  既然无缘
    2020-12-18 08:55

    I did some research and amongst other things I found this thread. It elaborates upon a similar issue that you're having (of the button not gaining focus). Try the following: On your buttons, set setFocusable(true) (NOT setFocusableInTouchMode! As this spawns the annoying behaviour you stated in your OP), then set the following OnClickListener on your Buttons:

        return new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
                // TODO workaround because of android issue nr. 2705
                button.requestFocusFromTouch();
                // Do some stuff to handle OnClick
            }
        };
    

    But they should probably just fix the focus stuff for buttons, the current behaviour really does cause some issues (like yours).

提交回复
热议问题