How to focus on Webview upon selecting an EditText within same Layout in Android?

心不动则不痛 提交于 2019-12-01 11:03:56
Adnan Zahid

I encountered the same problem a few weeks ago. The answer is simple, set an onTouchListener to the webview and then set it up as follows:

public boolean onTouch(View v, MotionEvent event) {
    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
    case MotionEvent.ACTION_UP:
        if (!v.hasFocus()) {
            v.requestFocus();
        }
        break;
    }
    return false;
}

Edit: Infact I found an exact duplicate in the "Related" category, read this.

Let me know if its not what you're looking for.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!