事件上的EditText [英] Event on EditText

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

问题描述

我有一个EditText上的名字说EID ..now我要的是只要用户输入的EID值..an另一个EditText上说,OID现在OID应自动生成它的价值出EID输入值的..所以这事件我应该使用上面要执行的任务..
plz帮助我在android的非常新的

I have one edittext name say eid ..now what i want is as soon as user enter eid value ..an another edittext say "oid" now oid should automatically generate it's value out of the value entered in eid ..so which event should i use to perform above task.. plz help i am very new in android

推荐答案

您可以编辑文本使用textWatcher,它会在编辑文本的种种变化,并触发相应的功能。

You can use textWatcher on Edit Text, it gets all the changes in Edit Text, and triggers appropriate functions.

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

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

    }

    public void afterTextChanged(Editable s) {
        // set oid value now
        oid.setText(eid.getText().toString());
    }
});

每当文本将改变开斋节的方法afterTextChanged将被调用的,它会设定值也OID

Whenever the text will change of "eid" method afterTextChanged will be called and it will set the value of oid also.

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

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