处理 EditText 焦点的事件 [英] Event for Handling the Focus of the EditText

查看:21
本文介绍了处理 EditText 焦点的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以向我建议与 EditText 的焦点相关的任何事件吗?我的应用程序包含一个 EditText,它接受其中的 URL.

Can anyone suggest to me any event related to the focus of the EditText? My application contains an EditText, which accepts a URL in it.

现在我的问题是,在用户在字段中输入 URL 并进一步移动后,没有任何点击事件,即当焦点从 EditText 移动时,它应该检测输入的 Url 并转到服务器.

Now my problem is that, that after the user will enter the URL in the field and Move further, without any of the click events, i.e when the focus will move from the EditText, it should detect the entered Url and goes to the server.

如果我用Json Parsing得到回复,那会更方便.

If I get the reply using Json Parsing, then it'll be more convenient.

推荐答案

这里是焦点监听器的例子.

Here is the focus listener example.

editText.setOnFocusChangeListener(new OnFocusChangeListener() {
    @Override
    public void onFocusChange(View view, boolean hasFocus) {
        if (hasFocus) {
            Toast.makeText(getApplicationContext(), "Got the focus", Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(getApplicationContext(), "Lost the focus", Toast.LENGTH_LONG).show();
        }
    }
});

这篇关于处理 EditText 焦点的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆