jeudi 17 mars 2016

Setters are working but getters are not

i Have created a user class that i collect the data in

public class Users {
 private String name;


 public String getName() {
        return name;
    }
    public void setName(String name){
        this.name=name;
    }
}

then i take text from the user this way

Users users=new Users();
String name=editTextmain.getText().toString();
users.setName(name);

after that i want to view the name in a toast so i o this

Users users=new Users();
Toast.makeText(this,users.getName(),Toast.LENGTH_LONG).show();

the toast appears empty , any ideas?

Aucun commentaire:

Enregistrer un commentaire