I am using shared preference and if else condition but when i am clicking on login button without touching text box it starts another activity and after giving input in text box its working fine why?
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences sharedPref = getSharedPreferences("userinfo",Context.MODE_PRIVATE);
final String name =sharedPref.getString("username","");
if(userLogInText.getText().toString().trim().equalsIgnoreCase(name)){
Intent intent = new Intent(getApplicationContext(),MyActivity.class);
startActivity(intent);
}
else {
Toast.makeText(getApplicationContext(),"Registration ID is not Matching",Toast.LENGTH_LONG).show();
}
}
});
Aucun commentaire:
Enregistrer un commentaire