I have a very simple question for anyone who already understands Java but it's breaking my head.
Being direct, I have my MainActivity and a layout with two EditText's and a button, and a SystemHttp Class.
I wanted when I clicked on the button, the values of the fields went to SystemHttp, check the username and password and show the return in MainActivity.
The problem is that since I'm a Java inicator I can not do this, but I already have a (almost) function basis:
MainActivity:
txt_usuario = (EditText) findViewById(R.id.usuario);
txt_senha = (EditText) findViewById(R.id.senha);
btn_login = (Button) findViewById(R.id.btn_login);
btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String user = txt_usuario.getText().toString();
String pssw = txt_senha.getText().toString();
SistemaHttp sHttp = new SistemaHttp(getBaseContext());
sHttp.retornaUsuario(user, pssw);
}
});
SystemHttp:
public String retornaUsuario(String user, String pssw)
{
String u = "Teste";
String s = "123";
String resp = "";
if (user.equals(u) && pssw.equals(s))
{
resp = "OK";
}
else
{
resp = "ERRO";
}
MainActivity main = new MainActivity();
main.retornoLogin(resp);
}