Advertisement
Ahmad-Taufik

project

Aug 9th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.49 KB | None | 0 0
  1. Login xml
  2. <?xml version="1.0" encoding="utf-8"?>
  3. <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4. xmlns:app="http://schemas.android.com/apk/res-auto"
  5. xmlns:tools="http://schemas.android.com/tools"
  6. android:layout_width="match_parent"
  7. android:layout_height="match_parent"
  8. tools:context="id.anhs.bantuemart.ui.activity.main.LoginActivity"
  9. android:background="@color/colorPrimary">
  10. <ImageView
  11. android:layout_centerHorizontal="true"
  12. android:src="@mipmap/ic_launcher_shop_round"
  13. android:layout_width="160dp"
  14. android:layout_height="160dp"
  15. android:layout_marginRight="8dp"
  16. app:layout_constraintRight_toRightOf="parent"
  17. android:layout_marginLeft="8dp"
  18. app:layout_constraintLeft_toLeftOf="parent"
  19. app:layout_constraintTop_toTopOf="parent"
  20. android:layout_marginTop="8dp"
  21. android:layout_marginBottom="8dp"
  22. app:layout_constraintBottom_toTopOf="@+id/linearLayout"/>
  23. <LinearLayout
  24. android:layout_alignParentBottom="true"
  25. android:padding="30dp"
  26. android:orientation="vertical"
  27. android:layout_width="325dp"
  28. android:layout_height="295dp"
  29. android:layout_marginRight="8dp"
  30. app:layout_constraintRight_toRightOf="parent"
  31. android:layout_marginLeft="8dp"
  32. app:layout_constraintLeft_toLeftOf="parent"
  33. app:layout_constraintBottom_toBottomOf="parent"
  34. android:layout_marginBottom="8dp"
  35. android:id="@+id/linearLayout">
  36. <android.support.design.widget.TextInputLayout
  37. android:layout_width="match_parent"
  38. android:layout_height="60dp"
  39. android:background="@color/colorTextSelectedTab">
  40. <android.support.design.widget.TextInputEditText
  41. android:id="@+id/txtLoginEmail"
  42. android:layout_width="match_parent"
  43. android:layout_height="50dp"
  44. android:inputType="textEmailAddress"
  45. android:hint="Email"/>
  46. </android.support.design.widget.TextInputLayout>
  47. <android.support.design.widget.TextInputLayout
  48. android:layout_marginTop="12dp"
  49. android:layout_width="match_parent"
  50. android:layout_height="60dp"
  51. android:background="@color/colorTextSelectedTab">
  52. <android.support.design.widget.TextInputEditText
  53. android:id="@+id/txtLoginPassword"
  54. android:layout_width="match_parent"
  55. android:layout_height="wrap_content"
  56. android:inputType="textPassword"
  57. android:hint="Password"/>
  58. </android.support.design.widget.TextInputLayout>
  59. <Button
  60. android:id="@+id/btnLogin"
  61. android:background="@drawable/shape_rectangle_round"
  62. android:textColor="@color/colorPrimary"
  63. android:ems="10"
  64. android:layout_marginTop="16dp"
  65. android:layout_gravity="center"
  66. android:text="Login"
  67. android:layout_width="wrap_content"
  68. android:layout_height="wrap_content"
  69. android:textStyle="bold"/>
  70. <TextView
  71. android:textStyle="bold"
  72. android:id="@+id/txtCreateAcc"
  73. android:layout_marginTop="24dp"
  74. android:textAlignment="center"
  75. android:text="Buat Akun baru Disini !"
  76. android:layout_width="match_parent"
  77. android:layout_height="wrap_content"
  78. android:clickable="true"
  79. android:focusable="true"/>
  80. </LinearLayout>
  81.  
  82. </android.support.constraint.ConstraintLayout>
  83.  
  84. Login Java
  85. package id.anhs.bantuemart.ui.activity.main;
  86.  
  87. import android.annotation.SuppressLint;
  88. import android.content.Intent;
  89. import android.support.v7.app.AppCompatActivity;
  90. import android.os.Bundle;
  91. import android.view.View;
  92. import android.widget.Button;
  93. import android.widget.EditText;
  94. import android.widget.Toast;
  95. import butterknife.BindView;
  96. import android.widget.TextView;
  97.  
  98. import butterknife.ButterKnife;
  99. import id.anhs.bantuemart.R;
  100.  
  101.  
  102. public class LoginActivity extends AppCompatActivity {
  103. @BindView(R.id.txtCreateAcc) TextView txtCreateAcc;
  104. @SuppressLint("Assert")
  105. @Override
  106. protected void onCreate(Bundle savedInstanceState) {
  107. super.onCreate(savedInstanceState);
  108. setContentView(R.layout.activity_login);
  109. final EditText username = findViewById(R.id.txtLoginEmail);
  110. final EditText password = findViewById(R.id.txtLoginPassword);
  111. Button Login = findViewById(R.id.btnLogin);
  112.  
  113. ButterKnife.bind(this);
  114.  
  115. Login.setOnClickListener(new View.OnClickListener() {
  116. @Override
  117. public void onClick(View view) {
  118. String user = username.getText().toString();
  119. String pass_ = password.getText().toString();
  120. {
  121. Toast.makeText(getApplicationContext(), "Selamat Anda Berhasil Masuk", Toast.LENGTH_SHORT).show();
  122. Intent i = new Intent(LoginActivity.this, MainActivity.class);
  123. startActivity(i);
  124. }
  125. }
  126. });
  127. txtCreateAcc.setOnClickListener(new View.OnClickListener() {
  128. @Override
  129. public void onClick(View v) {
  130. Intent b = new Intent(LoginActivity.this, RegisterActivity.class);
  131. startActivity(b);
  132. }
  133. });
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement