Advertisement
Guest User

MyTask

a guest
Dec 18th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. activity_main
  2. ===========
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:layout_margin="16dp"
  7. android:orientation="vertical"> <!--because of edge phones-->
  8.  
  9. <!--place for logo -->
  10. <LinearLayout
  11. android:layout_width="match_parent"
  12. android:layout_height="match_parent"
  13. android:layout_weight="1"
  14. android:gravity="center"
  15. android:orientation="vertical">
  16.  
  17. <TextView
  18. android:layout_width="wrap_content"
  19. android:layout_height="wrap_content"
  20. android:text="My Task"
  21. android:textSize="64sp" />
  22. </LinearLayout>
  23.  
  24. <!--place for user input-->
  25. <LinearLayout
  26. android:layout_width="match_parent"
  27. android:layout_height="match_parent"
  28. android:layout_weight="1"
  29. android:gravity="center"
  30. android:orientation="vertical">
  31.  
  32. <EditText
  33. android:layout_width="match_parent"
  34. android:layout_height="wrap_content"
  35. android:hint="@string/userName"
  36. android:id="@+id/txtUser"/>
  37.  
  38. <EditText
  39. android:layout_width="match_parent"
  40. android:layout_height="wrap_content"
  41. android:layout_marginTop="20dp"
  42. android:hint="@string/userPass"
  43. android:inputType="textPassword"
  44. android:id="@+id/txtPass"/>
  45. </LinearLayout>
  46.  
  47. <!--place for buttons-->
  48. <LinearLayout
  49. android:layout_width="match_parent"
  50. android:layout_height="match_parent"
  51. android:layout_weight="1"
  52. android:gravity="top"
  53. android:orientation="horizontal">
  54.  
  55. <Button
  56. android:layout_width="match_parent"
  57. android:layout_height="wrap_content"
  58. android:layout_margin="20dp"
  59. android:layout_weight="1"
  60. android:background="#009fff"
  61. android:text="@string/register"
  62. android:textColor="#ffffff"
  63. android:textSize="22sp"
  64. android:id="@+id/btnRegister"/>
  65.  
  66. <Button
  67. android:layout_width="match_parent"
  68. android:layout_height="wrap_content"
  69. android:layout_margin="20dp"
  70. android:layout_weight="1"
  71. android:background="#009fff"
  72. android:text="@string/login"
  73. android:textColor="#ffffff"
  74. android:textSize="22sp"
  75. android:id="@+id/btnLogin"/>
  76. </LinearLayout>
  77.  
  78. </LinearLayout>
  79.  
  80.  
  81.  
  82.  
  83. strings.xml
  84. ===========
  85. <resources>
  86. <string name="app_name">MyTask</string>
  87. <string name="userName">Enter your user name..</string>
  88. <string name="userPass">Enter your password..</string>
  89. <string name="login">Login</string>
  90. <string name="register">Register</string>
  91. </resources>
  92.  
  93.  
  94.  
  95.  
  96. MainActivity
  97. ===========
  98. package com.example.android.mytask;
  99.  
  100. import android.support.v7.app.AppCompatActivity;
  101. import android.os.Bundle;
  102. import android.widget.EditText;
  103.  
  104. public class MainActivity extends AppCompatActivity {
  105. EditText txtUser, txtPass;
  106.  
  107. @Override
  108. protected void onCreate(Bundle savedInstanceState) {
  109. super.onCreate(savedInstanceState);
  110. setContentView(R.layout.activity_main);
  111. setPointer();
  112. }
  113.  
  114. private void setPointer(){
  115. txtUser=findViewById(R.id.txtUser);
  116. txtPass=findViewById(R.id.txtPass);
  117.  
  118. //how to get data from EditText
  119. String userName = txtUser.getText().toString();
  120. }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement