Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent" android:baselineAligned="true">
- <RelativeLayout android:layout_height="350dip" android:id="@+id/relativeLayout1" android:layout_width="320dip">
- <TextView
- android:id="@+id/textView1"
- android:text="Signup"
- android:layout_alignParentLeft="true"
- android:layout_marginLeft="125dip"
- android:layout_height="50dip"
- android:textSize="30dip"
- android:layout_width="150dip">
- </TextView>
- <EditText
- android:layout_alignParentLeft="true"
- android:id="@+id/uname"
- android:layout_height="wrap_content"
- android:hint="Username"
- android:layout_marginTop="50dip"
- android:layout_width="320dip">
- </EditText>
- <EditText
- android:layout_width="wrap_content"
- android:id="@+id/email"
- android:layout_below="@+id/uname"
- android:layout_height="wrap_content"
- android:hint="Email Address"
- android:layout_alignLeft="@+id/uname"
- android:layout_alignRight="@+id/uname">
- </EditText>
- <EditText
- android:layout_width="wrap_content"
- android:id="@+id/password"
- android:layout_below="@+id/email"
- android:layout_height="wrap_content"
- android:hint="Password"
- android:inputType="textPassword"
- android:layout_alignLeft="@+id/email"
- android:layout_alignRight="@+id/email">
- </EditText>
- <EditText
- android:layout_width="wrap_content"
- android:id="@+id/fname"
- android:layout_below="@+id/password"
- android:layout_height="wrap_content"
- android:hint="First Name"
- android:layout_alignLeft="@+id/password"
- android:layout_alignRight="@+id/password">
- </EditText>
- <EditText
- android:layout_width="wrap_content"
- android:id="@+id/lname"
- android:layout_below="@+id/fname"
- android:layout_height="wrap_content"
- android:hint="Last Name"
- android:layout_alignLeft="@+id/fname"
- android:layout_alignRight="@+id/fname">
- </EditText>
- <Button
- android:id="@+id/register"
- android:layout_below="@+id/lname"
- android:text="Register"
- android:layout_height="wrap_content"
- android:layout_width="150dip"
- android:layout_marginLeft="80dip">
- </Button>
- </RelativeLayout>
- </LinearLayout>
- registration
- registration.java
- package com.android;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.Toast;
- public class registration extends Activity {
- Button register;
- EditText uname,email,password,fname,lname;
- DBhandler db;
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.registration);
- uname = (EditText) findViewById(R.id.uname);
- email = (EditText) findViewById(R.id.email);
- password = (EditText) findViewById(R.id.password);
- fname = (EditText) findViewById(R.id.fname);
- lname = (EditText) findViewById(R.id.lname);
- register = (Button) findViewById(R.id.register);
- db = new DBhandler(this);
- register.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- // TODO Auto-generated method stub
- if(v==register)
- {
- Users us = new Users();
- String u = uname.getText().toString();
- us.setUsername(u);
- String p = password.getText().toString();
- us.setPassword(p);
- String e = email.getText().toString();
- us.setEmail(e);
- String f = fname.getText().toString();
- us.setFname(f);
- String l = lname.getText().toString();
- us.setLname(l);
- db.register(us);
- Toast toast = Toast.makeText(getApplicationContext(), "Your account has been successfully created!", Toast.LENGTH_SHORT);
- toast.show();
- }
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement