Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Login xml
- <?xml version="1.0" encoding="utf-8"?>
- <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context="id.anhs.bantuemart.ui.activity.main.LoginActivity"
- android:background="@color/colorPrimary">
- <ImageView
- android:layout_centerHorizontal="true"
- android:src="@mipmap/ic_launcher_shop_round"
- android:layout_width="160dp"
- android:layout_height="160dp"
- android:layout_marginRight="8dp"
- app:layout_constraintRight_toRightOf="parent"
- android:layout_marginLeft="8dp"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- android:layout_marginTop="8dp"
- android:layout_marginBottom="8dp"
- app:layout_constraintBottom_toTopOf="@+id/linearLayout"/>
- <LinearLayout
- android:layout_alignParentBottom="true"
- android:padding="30dp"
- android:orientation="vertical"
- android:layout_width="325dp"
- android:layout_height="295dp"
- android:layout_marginRight="8dp"
- app:layout_constraintRight_toRightOf="parent"
- android:layout_marginLeft="8dp"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintBottom_toBottomOf="parent"
- android:layout_marginBottom="8dp"
- android:id="@+id/linearLayout">
- <android.support.design.widget.TextInputLayout
- android:layout_width="match_parent"
- android:layout_height="60dp"
- android:background="@color/colorTextSelectedTab">
- <android.support.design.widget.TextInputEditText
- android:id="@+id/txtLoginEmail"
- android:layout_width="match_parent"
- android:layout_height="50dp"
- android:inputType="textEmailAddress"
- android:hint="Email"/>
- </android.support.design.widget.TextInputLayout>
- <android.support.design.widget.TextInputLayout
- android:layout_marginTop="12dp"
- android:layout_width="match_parent"
- android:layout_height="60dp"
- android:background="@color/colorTextSelectedTab">
- <android.support.design.widget.TextInputEditText
- android:id="@+id/txtLoginPassword"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:inputType="textPassword"
- android:hint="Password"/>
- </android.support.design.widget.TextInputLayout>
- <Button
- android:id="@+id/btnLogin"
- android:background="@drawable/shape_rectangle_round"
- android:textColor="@color/colorPrimary"
- android:ems="10"
- android:layout_marginTop="16dp"
- android:layout_gravity="center"
- android:text="Login"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textStyle="bold"/>
- <TextView
- android:textStyle="bold"
- android:id="@+id/txtCreateAcc"
- android:layout_marginTop="24dp"
- android:textAlignment="center"
- android:text="Buat Akun baru Disini !"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:clickable="true"
- android:focusable="true"/>
- </LinearLayout>
- </android.support.constraint.ConstraintLayout>
- Login Java
- package id.anhs.bantuemart.ui.activity.main;
- import android.annotation.SuppressLint;
- import android.content.Intent;
- 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;
- import butterknife.BindView;
- import android.widget.TextView;
- import butterknife.ButterKnife;
- import id.anhs.bantuemart.R;
- public class LoginActivity extends AppCompatActivity {
- @BindView(R.id.txtCreateAcc) TextView txtCreateAcc;
- @SuppressLint("Assert")
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_login);
- final EditText username = findViewById(R.id.txtLoginEmail);
- final EditText password = findViewById(R.id.txtLoginPassword);
- Button Login = findViewById(R.id.btnLogin);
- ButterKnife.bind(this);
- Login.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- String user = username.getText().toString();
- String pass_ = password.getText().toString();
- {
- Toast.makeText(getApplicationContext(), "Selamat Anda Berhasil Masuk", Toast.LENGTH_SHORT).show();
- Intent i = new Intent(LoginActivity.this, MainActivity.class);
- startActivity(i);
- }
- }
- });
- txtCreateAcc.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent b = new Intent(LoginActivity.this, RegisterActivity.class);
- startActivity(b);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement