Advertisement
Guest User

Untitled

a guest
May 20th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.49 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent" android:baselineAligned="true">
  6. <RelativeLayout android:layout_height="350dip" android:id="@+id/relativeLayout1" android:layout_width="320dip">
  7. <TextView
  8. android:id="@+id/textView1"
  9. android:text="Signup"
  10. android:layout_alignParentLeft="true"
  11. android:layout_marginLeft="125dip"
  12. android:layout_height="50dip"
  13. android:textSize="30dip"
  14. android:layout_width="150dip">
  15. </TextView>
  16. <EditText
  17. android:layout_alignParentLeft="true"
  18. android:id="@+id/uname"
  19. android:layout_height="wrap_content"
  20. android:hint="Username"
  21. android:layout_marginTop="50dip"
  22. android:layout_width="320dip">
  23. </EditText>
  24. <EditText
  25. android:layout_width="wrap_content"
  26. android:id="@+id/email"
  27. android:layout_below="@+id/uname"
  28. android:layout_height="wrap_content"
  29. android:hint="Email Address"
  30. android:layout_alignLeft="@+id/uname"
  31. android:layout_alignRight="@+id/uname">
  32. </EditText>
  33. <EditText
  34. android:layout_width="wrap_content"
  35. android:id="@+id/password"
  36. android:layout_below="@+id/email"
  37. android:layout_height="wrap_content"
  38. android:hint="Password"
  39. android:inputType="textPassword"
  40. android:layout_alignLeft="@+id/email"
  41. android:layout_alignRight="@+id/email">
  42. </EditText>
  43. <EditText
  44. android:layout_width="wrap_content"
  45. android:id="@+id/fname"
  46. android:layout_below="@+id/password"
  47. android:layout_height="wrap_content"
  48. android:hint="First Name"
  49. android:layout_alignLeft="@+id/password"
  50. android:layout_alignRight="@+id/password">
  51. </EditText>
  52. <EditText
  53. android:layout_width="wrap_content"
  54. android:id="@+id/lname"
  55. android:layout_below="@+id/fname"
  56. android:layout_height="wrap_content"
  57. android:hint="Last Name"
  58. android:layout_alignLeft="@+id/fname"
  59. android:layout_alignRight="@+id/fname">
  60. </EditText>
  61. <Button
  62. android:id="@+id/register"
  63. android:layout_below="@+id/lname"
  64. android:text="Register"
  65. android:layout_height="wrap_content"
  66. android:layout_width="150dip"
  67. android:layout_marginLeft="80dip">
  68. </Button>
  69. </RelativeLayout>
  70. </LinearLayout>
  71. registration
  72.  
  73.  
  74.  
  75.  
  76.  
  77. registration.java
  78.  
  79. package com.android;
  80.  
  81. import android.app.Activity;
  82. import android.os.Bundle;
  83. import android.view.View;
  84. import android.widget.Button;
  85. import android.widget.EditText;
  86. import android.widget.Toast;
  87.  
  88. public class registration extends Activity {
  89. Button register;
  90. EditText uname,email,password,fname,lname;
  91. DBhandler db;
  92. public void onCreate(Bundle savedInstanceState) {
  93. super.onCreate(savedInstanceState);
  94. setContentView(R.layout.registration);
  95. uname = (EditText) findViewById(R.id.uname);
  96. email = (EditText) findViewById(R.id.email);
  97. password = (EditText) findViewById(R.id.password);
  98. fname = (EditText) findViewById(R.id.fname);
  99. lname = (EditText) findViewById(R.id.lname);
  100. register = (Button) findViewById(R.id.register);
  101. db = new DBhandler(this);
  102.  
  103. register.setOnClickListener(new View.OnClickListener() {
  104.  
  105. public void onClick(View v) {
  106. // TODO Auto-generated method stub
  107. if(v==register)
  108. {
  109. Users us = new Users();
  110. String u = uname.getText().toString();
  111. us.setUsername(u);
  112. String p = password.getText().toString();
  113. us.setPassword(p);
  114. String e = email.getText().toString();
  115. us.setEmail(e);
  116. String f = fname.getText().toString();
  117. us.setFname(f);
  118. String l = lname.getText().toString();
  119. us.setLname(l);
  120. db.register(us);
  121.  
  122. Toast toast = Toast.makeText(getApplicationContext(), "Your account has been successfully created!", Toast.LENGTH_SHORT);
  123. toast.show();
  124. }
  125. }
  126. });
  127. }
  128.  
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement