I am trying to work with editText for my android app log in screen. No matter how I try to get it to work it never does! Currently I'm just trying to compare the editText field to a single letter string, then if it matches call a function to start a new activity.
Any help is greatly appreciated! My end goal is to make two toast messages. If there is not input, then it says "Please enter username and password" and if it is wrong it will say "Wrong username password combination". Then if it matches, the app will simply go to the next page, titled "Device Page". Thanks again!!
package com.example.chirp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class LogIn extends Activity{
EditText edit_text;
//
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loginscreen);
edit_text = (EditText)findViewById(R.id.editText2);
login = (Button)findViewById(R.id.button1);
login.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{
// Log.v("EditText value=", edit_text.getText().toString());
if(edit_text.getText().toString() == "d")
{
newscreen();
}
}
});
}
public void newscreen(){
Intent i = new Intent(this, Devices.class);
startActivity (i);
}
}