自动单击“提交"按钮,以及如何通过“提交"按钮的时间限制? [英] Automatically click submit button and how to pass time limit on submit button?

查看:133
本文介绍了自动单击“提交"按钮,以及如何通过“提交"按钮的时间限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的想法是,在应用程序中,有两个views,一个是editText,另一个是Submit button,当单击editText时,一些预设字符将被粘贴到editText中,并且然后单击提交按钮发送这些字符.目前,完成了一半的工作.可以将预设字符粘贴到editText字段中,但仍需要手动单击提交"按钮.因此,另一半工作是在editText被填充时是否自动单击提交"按钮.填充editText时,我可以设置自动单击的软键盘上的提交按钮吗?

My idea, in app, there are two views, one is editText and another is submit button, when click editText, some pre-set characters will be pasted into the editText, and then click submit button to send these characters. For now, half work done is done. Pre-set characters can be pasted into editText field, but still need click submit button manually. so another half work is if or not when editText being filled, submit button will be clicked automatically. can I set submit button on soft keyboard clicked automatically when editText is being filled?

另一个问题是在另一个应用程序中,提交"按钮仅限于在特定时间(也许一秒钟)内单击,仍然不知道如何通过此时间限制.呼叫系统时间并设置系统时间是否提前一秒?可以超过此时间限制?

Another issue is in another app, submit button is being limited to click with specific time, maybe one second, still no idea about how to pass through this time limit. call system time and set up system time one second advanced? that can pass this time limit?

推荐答案

您可以使用TextWatcher监视EditText的更改.

You can use a TextWatcher to monitor the EditText for changes.

您可以像这样使用TextWatcher:

editText.addTextChangedListener(new TextWatcher() {
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void afterTextChanged(Editable s) {
        submitButton.performClick();
    }
});

使用TextWatcher,您可以响应与输入EditText中的文本有关的某些事件.在此示例中,我模拟了更改文本后在Button上的单击.

With a TextWatcher, you can respond to certain events related to the text entered into the EditText. With this example, I'm simulating a click on the Button after text has been changed.

这篇关于自动单击“提交"按钮,以及如何通过“提交"按钮的时间限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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