简体   繁体   English

如何清除属于另一个类的文本编辑字段

[英]How to clear a text edit field that belongs from another class

I am trying to clear the edit text field that belongs to another class from another class.我正在尝试从另一个类中清除属于另一个类的编辑文本字段。 How to do this?这该怎么做? Example i want to clear the edit text username which is in the Login class from the registration class.示例我想从注册类中清除登录类中的编辑文本用户名。 I am new to android我是安卓新手

Clear edittext values by calling et.settext("").通过调用 et.settext("") 清除 edittext 值。 Just after successfully login from the same Activity.. This way u dont need to do it from diff class...在从同一个活动成功登录后..这样你就不需要从差异类来做......

Try this..试试这个..

    public class Registration{

    public Login l;

    public void doEdit(){

    l = new Login();

    l.setUserName("");   // setUserName is the Method in Login class to set Username.

    }


}
 Login myLogin = new Login;


myLogin.clearLogin();


class Login
{
    public clearLogin()
    {
        textField.setText("");
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM