Contoh Coding Login Java Android Studio






public class LoginActivity extends AppCompatActivity {


    private AutoCompleteTextView mEmailView;
    private EditText mPasswordView;
    myDbAdapter helper;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        // Set up the login form.        mEmailView = (AutoCompleteTextView) findViewById(R.id.email);

        helper = new myDbAdapter(this);

        mPasswordView = (EditText) findViewById(R.id.password);

        Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
        mEmailSignInButton.setOnClickListener(new OnClickListener() {
            @Override            public void onClick(View view) {
                // attemptLogin();
                if ( TextUtils.isEmpty(mEmailView.getText()))
                {
                    Message.message(getApplicationContext(),"Harap Lengkapi Form");


                }else if (TextUtils.isEmpty(mPasswordView.getText())){
                    Message.message(getApplicationContext(),"Harap Lengkapi Form");
                }


                else
                {
                    int a= helper.Login(mEmailView.getText().toString(),mPasswordView.getText().toString());
                    if(a<=0)
                    {
                        Message.message(getApplicationContext(),"Password/Username Salah");

                    }
                    else                    {
                        startActivity(new Intent(LoginActivity.this, test.class));
                        finish();
                    }
                }

            }
        });


    }



}

Tidak ada komentar