Advertisement
Guest User

zeev

a guest
Feb 28th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. main activity XML
  2. ===================
  3. <LinearLayout
  4. android:orientation="vertical"
  5. xmlns:android="http://schemas.android.com/apk/res/android"
  6. android:layout_width="match_parent"
  7. android:layout_height="match_parent">
  8.  
  9. <LinearLayout
  10. android:layout_width="match_parent"
  11. android:layout_height="match_parent"
  12. android:layout_weight="1">
  13. <ImageView
  14. android:layout_width="match_parent"
  15. android:layout_height="match_parent"
  16. android:src="@drawable/logo"/>
  17. </LinearLayout>
  18.  
  19. <RelativeLayout
  20. android:layout_width="match_parent"
  21. android:layout_height="match_parent"
  22. android:layout_weight="1"
  23. android:gravity="center">
  24. <EditText
  25. android:layout_width="match_parent"
  26. android:layout_height="wrap_content"
  27. android:inputType="text"
  28. android:hint="@string/enterUser"
  29. android:textSize="24sp"
  30. android:id="@+id/userName"
  31. android:gravity="center" />
  32. <EditText
  33. android:layout_width="match_parent"
  34. android:layout_height="wrap_content"
  35. android:inputType="textPassword"
  36. android:hint="@string/enterPass"
  37. android:textSize="24sp"
  38. android:layout_below="@id/userName"
  39. android:id="@+id/userPass"
  40. android:gravity="center" />
  41. </RelativeLayout>
  42.  
  43. <LinearLayout
  44. android:layout_width="match_parent"
  45. android:layout_height="match_parent"
  46. android:layout_weight="1"
  47. android:gravity="center">
  48. <Button
  49. android:layout_width="match_parent"
  50. android:layout_height="wrap_content"
  51. android:textSize="24sp"
  52. android:text="Login to system"
  53. android:onClick="btnLogin"/>
  54. </LinearLayout>
  55. </LinearLayout>
  56.  
  57. mainActivity.java
  58. ======================
  59.  
  60. package com.example.app0811.mylogin;
  61.  
  62. import android.app.Activity;
  63. import android.os.Bundle;
  64. import android.view.View;
  65. import android.widget.EditText;
  66. import android.widget.Toast;
  67.  
  68. public class MainActivity extends Activity
  69. {
  70. EditText txtUser;
  71. EditText txtPass;
  72. @Override
  73. protected void onCreate(Bundle savedInstanceState)
  74. {
  75. super.onCreate(savedInstanceState);
  76. setContentView(R.layout.activity_main);
  77. setPointer();
  78. }
  79.  
  80. private void setPointer()
  81. {
  82. txtUser=(EditText)findViewById(R.id.userName);
  83. txtPass=(EditText)findViewById(R.id.userPass);
  84. }
  85.  
  86.  
  87. public void btnLogin(View v)
  88. {
  89. String chkUser= txtUser.getText().toString();
  90. String chkPass=txtPass.getText().toString();
  91.  
  92. if (chkUser.toLowerCase().equals("eyob") && chkPass.equals("1234"))
  93. Toast.makeText(this,"Hello master....",Toast.LENGTH_LONG).show();
  94. else
  95. Toast.makeText(this,"Who are you???",Toast.LENGTH_LONG).show();
  96. }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement