登录页面.class
public class MainActivity extends Activity {
TextView tv;
Button b1,b2,b3;
ImageButton ib1,ib2;
EditText e1,e2;
ImageView iv;
LoginDataBaseAdapter loginDataBaseAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
loginDataBaseAdapter=new LoginDataBaseAdapter(this);
loginDataBaseAdapter=loginDataBaseAdapter.open();
e1=(EditText)findViewById(R.id.et_username);
e2=(EditText)findViewById(R.id.et_password);
iv=(ImageView)findViewById(R.id.iv_search);
tv=(TextView)findViewById(R.id.tv_login_heading);
b3=(Button)findViewById(R.id.btn_register);
b1=(Button)findViewById(R.id.image_login);
ib1=(ImageButton)findViewById(R.id.ib_username);
ib2=(ImageButton)findViewById(R.id.ib_password);
b2=(Button)findViewById(R.id.btn_login_notnow);
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String userName=e1.getText().toString();
String password=e2.getText().toString();
if(password.equals(password))
{
Toast.makeText(MainActivity.this, "Congrats: Login Successfull", Toast.LENGTH_LONG).show();
Log.i(""+userName, "name");
Log.i(""+password, "pass");
Intent intent=new Intent(MainActivity.this,JobsCategery.class);
startActivity(intent);
}
else
{
Toast.makeText(MainActivity.this, "User Name or Password does not match", Toast.LENGTH_LONG).show();
}
}
});
b2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.i("clixk","notnow");
}
});
b3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.i("click","sucess");
Intent intent1=new Intent(MainActivity.this,RegisterActivity.class);
startActivity(intent1)
; }
});
}
}
这是我尝试登录时的登录页面,它从错误的用户名和密码成功登录。我想使用正确的代码。
在我的新用户注册的注册页面中,他们都采用了错误的值并获得了成功。我想要有效的代码。
注册.java
public class RegisterActivity extends Activity{
TextView tv1,tv2;
Button b;
EditText e1,e2,e3,e4,e5,e6;
ImageView iv;
SignupDtaBaseAdapter signDataBaseAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.register);
// get Instance of Database Adapter
signDataBaseAdapter=new SignupDtaBaseAdapter(this);
signDataBaseAdapter=signDataBaseAdapter.open();
tv1=(TextView)findViewById(R.id.tv_register_job);
tv2=(TextView)findViewById(R.id.tv_fill_data);
b=(Button)findViewById(R.id.btn_register);
e1=(EditText)findViewById(R.id.et_email);
e2=(EditText)findViewById(R.id.et_name);
e3=(EditText)findViewById(R.id.et_password);
e4=(EditText)findViewById(R.id.et_phone);
e5=(EditText)findViewById(R.id.et_repass);
e6=(EditText)findViewById(R.id.et_username);
iv=(ImageView)findViewById(R.id.iv_search);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String emailid=e1.getText().toString();
String name=e2.getText().toString();
String password=e3.getText().toString();
String contact=e4.getText().toString();
String retypepassword=e5.getText().toString();
String userName=e6.getText().toString();
// check if any of the fields are vaccant
if(userName.equals("")||password.equals("")||emailid.equals("")||name.equals("")||retypepassword.equals("")||contact.equals(""))
{
Toast.makeText(getApplicationContext(), "Field Vaccant", Toast.LENGTH_LONG).show();
return;
}
Log.i(""+userName, "name");
Log.i(""+password, "pass");
Log.i(""+emailid, "mailid");
Log.i(""+name, "name");
Log.i(""+contact, "contact");
Log.i(""+retypepassword,"retypepassword");
Toast.makeText(getApplicationContext(), "Account Successfully Created ", Toast.LENGTH_LONG).show();
Intent intent=new Intent(RegisterActivity.this,MainActivity.class);
startActivity(intent);
}
});
}
}