且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android:用户完成编辑后评估 EditText

更新时间:2022-02-21 06:20:10

我做了一些研究,发现这个线程.它详细说明了您遇到的类似问题(按钮没有获得焦点).请尝试以下操作:在您的按钮上,设置 setFocusable(true)(不是 setFocusableInTouchMode!因为这会产生您在 OP 中声明的烦人行为),然后在您的按钮上设置以下 OnClickListener:

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).