Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.tugas;
- import android.content.Intent;
- import android.support.v7.app.AlertDialog;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.Toast;
- public class MainActivity extends AppCompatActivity {
- EditText username, password;
- Button btnLogin;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- username = (EditText) findViewById(R.id.username);
- password = (EditText) findViewById(R.id.password);
- btnLogin = (Button)findViewById(R.id.login);
- }
- public void masuk(View view) {
- String usernameKey = username.getText().toString();
- String passwordKey = password.getText().toString();
- if (usernameKey.equals("admin") && passwordKey.equals("admin")){
- Toast.makeText(getApplicationContext(), "LOGIN SUKSES",
- Toast.LENGTH_SHORT).show();
- Intent intent = new Intent(MainActivity.this, Menu.class);
- MainActivity.this.startActivity(intent);
- finish();
- }else {
- AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
- builder.setMessage("Username atau Password Anda salah!")
- .setNegativeButton("Retry", null).create().show();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement